Basic Output
Today we are going to start printing text to the console. I’m going to start by showing you a simple Hello World program.
Basically we used the Python built-in function “print()” which takes a parameter that will be displayed to the console. Another example is the next one:
Unlike the first example, here we didn’t give the function a string as a parameter. Instead we provided a multiplication between integers that will be displayed by the console as the number 4.
User Input
What if we want the user to give us his/her age? First of all we need a variable to store what the user is going to provide. If we are going to ask the user for his age, we first need to know what the type of variable we are going to use. Since a person’s age must be an integer, the type of variable we are going to use will be an integer. Therefore:
If we run this program the console is going to look like this:
Great! Now you are ready to start playing with input and output.