← All tools
Computing

Python – Lesson 4: Lists & Turtle

Start with how to open, save and run Python, then work through the lesson: lists, Turtle drawing and the challenges.

How do I start Python?

Follow these five steps every time you write a program in IDLE.

0 of 5 steps done
1

Open IDLE Python

Go to START > ICT > IDLE PYTHON.

The Windows Start button IDLE (Python 3.6 32-bit) desktop app in the Start menu
2

Open a new file

Click on FILE > NEW FILE.

You can also press Ctrl + N to open a new window.

Python Shell File menu with New File (Ctrl+N) highlighted
3

Write your program

Write out your program for each task in the new window. For example:

print ("Test!")
An Untitled IDLE window containing print("Test!")
4

Save your program

Click on FILE > SAVE and give it a name.

You need to save to PC > Your Drive, Y9 IT
IDLE File menu with Save (Ctrl+S) highlighted
5

Run your program

Press RUN > RUN MODULE to run your program.

You can also press F5 to run your program as well.

IDLE Run menu with Run Module (F5) highlighted
✔ All five steps done — you're ready to start the lesson tasks below!

Lesson 4 – Python lists and Turtle

Work through each part in order. Put your screenshots and answers in your lesson document.

Learning objectives

  • What is a list?
  • What can Turtle Python do?

What we will be covering

  • How we can store data in a list and make changes to it.
  • How we can use Turtle in Python to draw shapes.

Do now

If you drew these steps on a piece of paper, what would you get?

  1. PEN DOWN
  2. DRAW FORWARD 10
  3. PEN TURN LEFT
  4. DRAW FORWARD 10
  5. PEN TURN LEFT
  6. DRAW FORWARD 10
  7. PEN TURN LEFT
  8. DRAW FORWARD 10
  9. PEN TURN LEFT
A square drawn by the turtle

Lists

In Python, a list stores a collection of items. Lists can hold different types of data — integers, floats, strings, or even other lists. You make one by putting items inside square brackets [ ], separated by commas.

Think of a list like a digital backpack: you can throw in all kinds of stuff — books, snacks, gadgets, whatever! Each thing in the backpack is an element in the list. And your backpack isn't picky, so ["pizza", 42, 3.14, "robot"] is totally fine.

A handwritten shopping list What's in my backpack: lots of different items A robot holding a pizza

How to make a list in Python

Make a list
list = ["cat", "bat", "dog"] print(list)
Output: ['cat', 'bat', 'dog']
Print one item from the list
print(list[1])
Output: bat
A list starts at position 0, then 1, 2, 3 for each position — so list[0] is "cat" and list[1] is "bat".
Add an item
list = ["cat", "bat", "dog"] list.append("T-REX") print(list)
Output: ['cat', 'bat', 'dog', 'T-REX']

Task 1 – Lists

Open Online Python →

Write out the following programs in Python and screenshot your evidence. Use IDLE (see How do I start Python?) or Online Python.

Program 1

names_list = []; for i in range(5): name = input('Enter a name: '); names_list.append(name); print('List of names:'); print(names_list)

Answer these questions:

  1. What does the for i in range(5) do?
  2. What are the 3 variables in this program called?
  3. How could we get the list to add more names?

Program 2

import random; name_list = ['Alice','Bob','Charlie','David','Eve']; random_name = random.choice(name_list); print(f'The chosen name is: {random_name}')

Answer these questions:

  1. What is import random?
  2. How many variables are in this program?
  3. What is this program doing?

Python Turtle

Python's turtle module is a powerful tool for learning programming through graphics. It gives you a simple, interactive way to create drawings, designs and even simple games.

Write out the following programs in Python and screenshot your evidence.

Code
import turtle turtle.forward(100) turtle.left(90) turtle.forward(100) turtle.left(90) turtle.forward(100) turtle.left(90) turtle.forward(100) turtle.left(90)
What you get A square

What you can use Turtle for

Code
import turtle length = 0 while True: length = length+1 turtle.forward(length) turtle.left(45)
What you get An octagon-shaped spiral

Write out the following programs and screenshot your drawing. For each one, explain what the code is doing.

1. Write out this code

import turtle; length=0; while True: length=length+1; turtle.forward(length); turtle.left(91)

2. Modify the code to look like this

Adds turtle.speed(1000) and alternates turtle.color red and yellow

3. Modify the code to look like this

Asks the user for length and angle with int(input()), then loops forward(length), left(angle), length=length+1

4. Write out this code

import turtle and random; loop picks a random colour from colorwheel list and random length 1-20, moves forward and turns left 90

For each one: screenshot of the drawing + what is this code doing?

Task 3 – Challenges

Choose one option to do. You can also do the Advanced challenge once you have done the Beginner one.

Option 1

Beginner

Draw a square using the turtle module. Allow the user to input the side length of the square.

Advanced

Create a program that draws a polygon with a user-specified number of sides. Allow the user to input the number of sides and the side length.

Option 2

Beginner

Create a program that draws a simple spirograph pattern. Allow the user to input the number of cycles and the radius of the pattern.

Advanced

Enhance the spirograph program to include multiple turtles, each drawing a different pattern with unique colours. Allow the user to customise the number of turtles and their properties.

Option 3

Beginner

Develop a simple interactive game using the turtle module — for example, the turtle moves in response to arrow key inputs from the user.

Advanced

Build a more complex game with obstacles, scoring and levels. Use collision detection to handle the turtle hitting obstacles. Control the turtle using arrow keys or other controls.

Feel free to modify and expand on these challenges based on your interests and skill level.

Evidence: screenshot + what is this code doing? Then complete your self-assessment and peer-assessment (WWW / EBI) in your lesson document.

Handy shortcuts

Ctrl + N
Open a new file
Ctrl + S
Save your program
F5
Run your program