Don't "hard" code - Introduction to Python: Absolute Beginner Module 2 Video 7
Concept: Don't "hard" code
Programming Style Tip: Avoid Hard-Coding
"Hard-coding" is placing data values directly into code
An example of hard-coding from above is have_hat = hat_available('green') where the argument 'green' is hard-coded
A programming best practice is to avoid hard-coding values when possible
Use variables and verse hard-coded (example: color = "green")
Often preferable to use input such as a configuration file (advanced topic) or user input.
These practices allow changing the data without disturbing the main code and makes code more reusable.
Task 2
Program: bird_available
The program should ask for user to "input a bird name to check for availability" and print a statement informing of availability
avoid hard coded values
create this program with a Boolean function bird_available()
has parameter that takes the name of a type of bird
for this exercise the variable bird_types = 'crow robin parrot eagle sandpiper hawk pigeon'
return True or False (we are making a Boolean function)
call the function using the name of a bird type from user input
print a sentence that indicates the availability of the type of bird checked
# [ ] create function bird_available
# [ ] user input
# [ ] call bird_available
# [ ] print availability status
Task 3
Fix The Error
# define function how_many
how_many():
requested = input("enter how many you want: ")
return requested
# get the number_needed
number_needed = how_many()
print(number_needed, "will be ordered")
Что делает видео по-настоящему запоминающимся? Наверное, та самая атмосфера, которая заставляет забыть о времени. Когда вы заходите на RUVIDEO, чтобы посмотреть онлайн «Don't "hard" code - Introduction to Python: Absolute Beginner Module 2 Video 7», вы рассчитываете на нечто большее, чем просто загрузку плеера. И мы это понимаем. Контент такого уровня заслуживает того, чтобы его смотрели в HD 1080, без дрожания картинки и бесконечного буферизации.
Честно говоря, Rutube сегодня — это кладезь уникальных находок, которые часто теряются в общем шуме. Мы же вытаскиваем на поверхность самое интересное. Будь то динамичный экшн, глубокий разбор темы от любимого автора или просто уютное видео для настроения — всё это доступно здесь бесплатно и без лишних формальностей. Никаких «заполните анкету, чтобы продолжить». Только вы, ваш экран и качественный поток.
Если вас зацепило это видео, не забудьте взглянуть на похожие материалы в блоке справа. Мы откалибровали наши алгоритмы так, чтобы они подбирали контент не просто «по тегам», а по настроению и смыслу. Ведь в конечном итоге, онлайн-кинотеатр — это не склад файлов, а место, где каждый вечер можно найти свою историю. Приятного вам отдыха на RUVIDEO!
Видео взято из открытых источников Rutube. Если вы правообладатель, обратитесь к первоисточнику.