Printing in Python

To output a message onto the screen use the print command. Then place your message within brackets and speech marks. For example:


When you press F5 (or click the ‘Run’ tab then ‘Run Module’), it will look like this:

print 2

Practice Task 1

 Printing over Several Lines

One way of writing over more than one line is to write several print commands like this:


But when we program we always want to make our code the most efficient it can be by using as few lines as possible. Therefore you can write \n within a printed statement to transfer it to the next line.

print 3

Both pieces of code display the same thing, but the second one is much more efficient.


Practice Task 2

< Back to Section One