2 Displaying Output – Printing messages


Printing and displaying output is an essential component of programming.

In Python we use the print() function / command.

You can identify a function by the () that it has (they are also used for creating classes and making our own functions but don’t worry about this yet).

Inside the ( ) you put the information that you want to have displayed.

Python works slightly differently to other languages with how some features of the print function works.

This example will focus on the basic operation of the function.

To print out text we need to make a String (the data type used to store text). Strings are enclosed in ” ” or ‘ ‘

So to print out the message Hello World we would write

print("Hello World")

To write numbers you can just write the number

print(331)

Try out these examples in Python

We can also combine difference values by using a comma , to separate the values.

print("Let's print a number", 764)

Note that when we do this there is a space placed between the two values.