Edexcel GCSE Computer Science June 2025 Paper 2, Question 5: nine coloured circles

Pearson Edexcel 1CP2/02 June 2025, Question 5: draw two axes and two diagonals, then nine circles of radius 75 stepping up and right by 30, cycling through a list of colours with a random pen width. A model answer, the fifteen marks explained, and a robot that drives the lines.

Past paper questionPearson 1CP2/02June 2025 Paper 215 marksWrite a program

Question 5 of the Pearson Edexcel GCSE Computer Science Paper 2 sat on 20 May 2025 (1CP2/02) is a 15 mark turtle graphics program written from a description. The turtle commands are the easy part. The marks are in the loop: nine circles, a colour that cycles, a width that is random, and a position that steps.

We do not copy the exam paper or Pearson's code files here. Open the paper beside this page: Edexcel June 2025 Paper 2 question paper (PDF). When you have finished, check the mark scheme too.

The question in short

The lines. Line A starts at (-200, 0) and line B at (0, 200), each 400 units long: a horizontal and a vertical axis. Lines C and D start at (-200, -200) and (200, -200), are at 45 degrees and 566 units long: the two diagonals. All black, width 3.

The circles. Nine circles of radius 75. The first is at the position stored in xPos and yPos. Each next one is 30 further up and 30 further right. The colours come from a list, used in turn, the same every run. The pen width for each circle is a random whole number from 5 to 10.

The turtle must go as fast as possible. The screen code is given.

Three things to get right

  • Cycling colours. With three colours and nine circles, circle number count uses myColours[count % 3]. The remainder goes 0, 1, 2, 0, 1, 2 ... The mark scheme refuses colours typed in by hand.
  • Random width. random.randint(5, 10) inside the loop, so each circle gets its own.
  • Stepping. xPos = xPos + 30 and yPos = yPos + 30 at the end of each pass.

A model answer

import turtle
import random

myColours = ["red", "green", "blue"]
xPos = -100
yPos = -100

screen = turtle.Screen()
theTurtle = turtle.Turtle()
theTurtle.speed(0)
theTurtle.pensize(3)
theTurtle.pencolor("black")

# lines A and B: the axes
theTurtle.penup()
theTurtle.setpos(-200, 0)
theTurtle.setheading(0)
theTurtle.pendown()
theTurtle.forward(400)
theTurtle.penup()
theTurtle.setpos(0, 200)
theTurtle.setheading(270)
theTurtle.pendown()
theTurtle.forward(400)

# lines C and D: the diagonals
theTurtle.penup()
theTurtle.setpos(-200, -200)
theTurtle.setheading(45)
theTurtle.pendown()
theTurtle.forward(566)
theTurtle.penup()
theTurtle.setpos(200, -200)
theTurtle.setheading(135)
theTurtle.pendown()
theTurtle.forward(566)

# nine circles
for count in range(9):
    theTurtle.penup()
    theTurtle.setpos(xPos, yPos)
    theTurtle.pendown()
    theTurtle.pencolor(myColours[count % 3])
    theTurtle.pensize(random.randint(5, 10))
    theTurtle.circle(75)
    xPos = xPos + 30
    yPos = yPos + 30

theTurtle.hideturtle()
turtle.done()

Where the fifteen marks are

Nine single marks: importing turtle and random; the fastest speed; lines A and B in the right places; lines C and D in the right places; a loop of nine; colours following the list's pattern, worked out in code; a random number from 5 to 10; a radius of 75; and both position variables stepping by 30. Then up to 3 for design (modulus for the colour is looked for) and 3 for functionality.

Where the marks are lost

  • myColours[count]. With three colours and nine circles that is an IndexError on the fourth circle. Modulus wraps it round.
  • The random width worked out once, before the loop. Every circle would be the same. It goes inside.
  • randint(5, 9). "Between five and ten" is inclusive here, and randint includes both ends.
  • Forgetting penup before setpos. The turtle drags a line to each new circle.
  • 135 for line D drawn from the wrong end. From (200, -200), going up and to the left is heading 135.

Run it

Turtle graphics does not run in this simulator, so the robot drives the four lines instead, scaled to the mat: along the axes, then the two diagonals. The nine circles are printed as the loop would draw them, with their colour and a random width.

The robot traces the two axes and the two diagonals. Then nine lines print the colour and width of each circle: the colours cycle red, green, blue and the widths vary each run.
The program
from bugbot import *
import random
connect()

SCALE = 0.08         # 400 units become 32 cm
myColours = ["red", "green", "blue"]
xPos = -100
yPos = -100

# line A, then back and up for line B
forward(60, distance=400 * SCALE)
backward(60, distance=200 * SCALE)
turn_left(30, angle=90)
forward(60, distance=200 * SCALE)
backward(60, distance=400 * SCALE)

# lines C and D
turn_left(30, angle=135)
forward(60, distance=566 * SCALE / 2)
backward(60, distance=566 * SCALE / 2)
turn_left(30, angle=90)
forward(60, distance=566 * SCALE / 2)
led("green")

for count in range(9):
    colour = myColours[count % 3]
    width = random.randint(5, 10)
    print("circle", count + 1, "at", xPos, yPos, colour, "width", width)
    xPos = xPos + 30
    yPos = yPos + 30
Put this demo on your own site

Paste it into a school website, Moodle, Google Sites or a blog. More options on the embed page.

Questions

How do I cycle through a list of colours in a loop?

Use the loop counter modulus the length of the list as the index: myColours[count % len(myColours)]. The index goes 0, 1, 2, 0, 1, 2 and never runs off the end.

How do I draw a circle in turtle graphics?

Move to where its bottom should be with penup, setpos and pendown, then call circle(radius). The circle is drawn upwards from the turtle's current position.

What heading draws a 45 degree diagonal?

setheading(45) heads up and to the right. setheading(135) heads up and to the left. The length of the diagonal of a 400 by 400 square is about 566.

More from this paper

Every Edexcel 1CP2 question we have worked

Learn it step by step

  1. F4.5 Libraries and your own modules Functions and structured code
  2. F3.7 Random numbers Strings, lists and records
Open the lessons

This is our own explanation of a published exam question. It is not written or endorsed by Pearson, and the question paper and mark scheme remain Pearson's copyright. Read them on Pearson's site with the links on this page.