jow does the input function work in python
Answers
Explanation:
input ( ) :
This function first takes the input from the user and then evaluates the expression, which means Python automatically identifies whether user entered a string or a number or list. If the input provided is not correct then either syntax error or exception is raised by python. For example –
# Python program showing
# a use of input()
val = input("Enter your value: ")
print(val)
Output: Enter your value:123
123
>>>
How the input function works in Python :
When input() function executes program flow will be stopped until the user has given an input.
The text or message display on the output screen to ask a user to enter input value is optional i.e. the prompt, will be printed on the screen is optional.
Whatever you enter as input, input function convert it into a string. if you enter an integer value still input() function convert it into a string. You need to explicitly convert it into an integer in your code using typecasting
Code:
# Program to check input
# type in Python
num = input ("Enter number :")
print(num)
name1 = input("Enter name : ")
print(name1)
# Printing type of input value
print ("type of number", type(num))
print ("type of name", type(name1))
this function first takes the input from the user and then evaluate the expression,which means python automatically identifies whether user entered a string or a number or list.if the input provided is not correct then either syntax error or exception is raised by python.

