RUVIDEO
Поделитесь видео 🙏

User Input and Type Casting in Python - 60 Seconds to Code

Welcome to 60 seconds to code where I show you how to code in 60 seconds or less.
Today you will learn about accepting use input and casting variable to different types.
Casting is the process of trying to convert one data type to another.
Step 1- Create a new file called useinput.py and type enterd_name = input('What is your name?') in line 1
Step 2 – Type print('Hello ' + enterd_name) in line 2. Since the input function returned a string, we can just pass it to the print function without any casting as print only accepts strings.
Step 3 – Type enterd_age = input('How old are you ' + enterd_name +'?') in line 3. If we want to do something with the age variable, we must cast to int.
Step 4 – Type print('You have ' + str(100-int(enterd_age)) + ' years untill your 100th birthday.') into line 4. Notice how the entered age is first cast to an integer using int, then subtracted from 100 and then cast back to a string using str.
Step 5 – Run the file and for practice, try casting a user input to a float data type. Also, can you think of what to do if the user does not provide a number for his age?
The code is available in a link in the description.
Congratulations, you’ve learned about user input and casting variable between different types. Save and push to Github and try to code a little every day because code is life.
#howto accept #userinput and how to #cast variables in #python #60secondstocode #codeislife


link to code: shorturl.at/rzEF6

Что делает видео по-настоящему запоминающимся? Наверное, та самая атмосфера, которая заставляет забыть о времени. Когда вы заходите на RUVIDEO, чтобы посмотреть онлайн «User Input and Type Casting in Python - 60 Seconds to Code», вы рассчитываете на нечто большее, чем просто загрузку плеера. И мы это понимаем. Контент такого уровня заслуживает того, чтобы его смотрели в HD 1080, без дрожания картинки и бесконечного буферизации.

Честно говоря, Rutube сегодня — это кладезь уникальных находок, которые часто теряются в общем шуме. Мы же вытаскиваем на поверхность самое интересное. Будь то динамичный экшн, глубокий разбор темы от любимого автора или просто уютное видео для настроения — всё это доступно здесь бесплатно и без лишних формальностей. Никаких «заполните анкету, чтобы продолжить». Только вы, ваш экран и качественный поток.

Если вас зацепило это видео, не забудьте взглянуть на похожие материалы в блоке справа. Мы откалибровали наши алгоритмы так, чтобы они подбирали контент не просто «по тегам», а по настроению и смыслу. Ведь в конечном итоге, онлайн-кинотеатр — это не склад файлов, а место, где каждый вечер можно найти свою историю. Приятного вам отдыха на RUVIDEO!

Видео взято из открытых источников Rutube. Если вы правообладатель, обратитесь к первоисточнику.