INPUT SYNTAX
code :
variable_name = input("pro in python")
output :
pro in python |
- variable_name : this is the variable where the program stores the input response.
- input(): this is the function to ask input and wait for their response .
- pro in python : this text will be displayed to the users asking them to type their input.
- In action : input()
lets try to use an example where we will use an input function to ask the user their name
code:
name = input("what is your name?")
output :
what is your name? |
when type a name and presses Enter the user input will be stored in variable 'name'.
output :
what is your name? |
^^^
program awaiting user response
what is your name?john
^^^^^
user response
john is now stored in the variable 'name'
user input : print or store
when user provides input you can directly display the input using the print()function , or you can save it in a variable for future use.
example:
code :
name = input("what is your name?")
print(name)
output :
what is your name? |
Enter name in additional input and press Enter
then output ;
what is your name?john
- You have to must try in your python compiler use idle avoid online compilers to Errors
- Quiz about Arithmetic Operations In Python
0 Comments