Basic Output and Input

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.

3.png

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:

4.png

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.

5.png

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:

1.png

If we run this program the console is going to look like this:

2.png

Great! Now you are ready to start playing with input and output.

Leave a comment