Drop hier links of afbeeldingen om ze aan de editor toe te voegen.

Output is how a computer presents the results of its processing back to you. It is the last step of the input, process, output cycle: data is collected and sent to the computer, the computer carries out its instructions, and the output presents the result. In this course, output means text appearing on the screen.

The print function

Python produces output with the print function. You write print, then a pair of brackets, and inside the brackets the text you want to see on the screen:

print("your text goes here")

When that line runs, Python writes the text to the screen:

your text goes here

Strings

The text inside the brackets is a string: the data type Python uses for text. A string is written between speech marks, and everything between them is treated as text, even when it is made up of digits:

print("Hello World!")
print("2024")

The second line outputs the characters 2024 as text, not the number 2024.

Try it yourself

Run the code below to see the output appear. Then change the text between the speech marks and run it again.

print("Hello World!")

Syntax: the way the code is written

Syntax is the format that code is written in. Python is precise: it only runs a line when that line follows the rules exactly. The print statement has three of them:

Incorrect syntax = broken code that will not work = an error!

Mistakes to watch out for

These four mistakes account for almost every broken print statement:

Mistake What it looks like
print written with a capital P Print("Hello World!")
A bracket missing at the start or the end print"Hello World!")
A speech mark missing at the start or the end print("Hello World!)
Pressing enter inside the string, which splits it over a new line print("Hello
World!")

Each of these stops your program from doing what you meant it to do, so it is worth checking them one by one whenever something goes wrong.