To get user input in console applications, we are using input function. This function gets a question string to be displayed to the user, and it captures all user input until the enter (line break). See it in action in the following example:

username = input( "Please tell me your name: " )
print( "Hello {0}, how are you?".format( username ) )

This sample outputs:

>>> Please tell me your name: matt
Hello matt, how are you?

Getting Number Inputs in Python

By default, input function returns user input as string. So, if you are willing to use the input in a numeric operation (addition, subtraction etc.), you need to convert that input to a number first. See it below:

birthyear = input( "What year were you born in? " )
age = 2018 - int( birthyear )
print( "Wow, you don't show your age {0} at all!".format( age ) )


>>>What year were you born in? 1980
Wow, you don't show your age 38 at all!

Of course, converting user input to number may not be always possible. So you need to wrap all conversions like this in try-except blocks.