Previous Post: https://codinghelp.site/wiki/python/2-python-print-function/
Next post: https://codinghelp.site/wiki/python/4-python-variables/
The “Input()” Function
Input is a built-in python function. It is used to get users input in the terminal/console.
The “input()” Function Syntax
Here, “__prompt” is representing a string that we have to pass in the parentheses of the INPUT() function. So for a example:
In the console it would look something alike…
Light green text is representing the user’s choice of input in the console. The function is usually put inside a variable, so we can retrieve the output.
Example
Here, we are assigning the value of whatever the user inputs to a variable named “name”. After the user inputs something, we are printing “Hello __entered name__, nice to meet you!”
__entered name__ is representing the users input in the console at the input function.
Exercise
Make a script that asks the user for their age then tell them how old they will be in 100 years. Make sure to make the variable an integer!
Answer key
