Simple Tutorial Python getting user input as string or int

Опубликовано: 28 Март 2023
на канале: Earth Walker
404
11

Simple python example and short video to illustrate the use of command input() to get in user input. Take note that regardless whether enter a number or a text or mixture of both, the input() will always get them in as a string value. If we want to store them as a numerical value like an integer so that we can perform some arithmetic operation like addition or subtraction, etc, we need to use int().

You can use the link below to see video information of summation and concatenation.
Apart from watching the video, you can also show more info to read on the explanation.
   • Tutorial Python variable summation and con...  

Beginner may get confused when they just need input() and when they need int(input()) in python.
This video explains why we need to use int().

int() is used top convert a string value into a integer value.
The below statement is converting a string value '3' into integer value 3.
burger = int('3')

if we need user to enter the value instead of always using 3, we replace '3' in the above statment with input() like below
burger = int(input('Enter the cost of the burger: '))

Please like the video if it helps you :)

Hope these inputs are helpful for you.

0:00 - XX
0:44 - XX


Keywords:
#python
#string
#integer
#variable
#summation
#concatenation
#simple
#quotes
#tutorial
#short
#easy
#+
#input()
#int()
#userinput #keyboard #keyboardInput


На этой странице сайта вы можете посмотреть видео онлайн Simple Tutorial Python getting user input as string or int длительностью часов минут секунд в хорошем качестве, которое загрузил пользователь Earth Walker 28 Март 2023, поделитесь ссылкой с друзьями и знакомыми, на youtube это видео уже посмотрели 404 раз и оно понравилось 11 зрителям. Приятного просмотра!