Python 3 user Input. | pycoder
Python3 user input
There are hardly any programs without any input. Input can come in various ways, for example, from a database, another computer, mouse clicks and movements or from the internet. Yet, in most cases the input stems from the keyboard. For this purpose, python provides the function input(). Input has an optional parameter, which is the prompt string.
If the input function is called, the program flow will be stopped until the user has given an input and has ended the input with the return key. The text of the optional parameter,
i.e. the prompt, will be printed on the scree.
The input of the user will be returned as a string without any changes. If this raw input has to be transformed into another data type needed by the algorithm, we can use either a casting function or the eval functon
python
name = input ("What is your name : ")
print ("welcome " , name)
output :
>>>What is your name : pycoder
welcome pycoder
There are hardly any programs without any input. Input can come in various ways, for example, from a database, another computer, mouse clicks and movements or from the internet. Yet, in most cases the input stems from the keyboard. For this purpose, python provides the function input(). Input has an optional parameter, which is the prompt string.
If the input function is called, the program flow will be stopped until the user has given an input and has ended the input with the return key. The text of the optional parameter,
i.e. the prompt, will be printed on the scree.
The input of the user will be returned as a string without any changes. If this raw input has to be transformed into another data type needed by the algorithm, we can use either a casting function or the eval functon
python
name = input ("What is your name : ")
print ("welcome " , name)
output :
>>>What is your name : pycoder
welcome pycoder
No comments: