Python 1a - Printing

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’), the text will print to the Python shell:

Practice Task 1

1. Print your full name to the screen.

2. On the next line, write another print statement to print the name of the person (or thing) to your left.

Example solution:

Printing over Several Lines

One way of writing across multiple lines is to write several print commands like this:


However, 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.


Both pieces of code display the same thing, but the second one is more efficient because it only uses one line.

Practice Task 2

1. On line 1 print your first name to the screen.

2. On line 2 print your favourite colour.

3. On line 3 print your favourite movie.

4. Run the program.

5. Now re-write your program to print the same output but using only line of code (Hint: use \n )

Example solution:

© CSNewbs 2021

The written, video and visual content of CSNewbs is protected by copyright. © 2020