Python, Concept by Concept › Turtle Geometry

Exercises: Turtle Geometry

Core work is Exercises 1–9. Exercises 10–15 are More Practice; Exercises 16–18 are optional Challenges. Each starter already runs and draws a small placeholder shape. Replace that placeholder with the requested program.

For every exercise, open the named file in assets/, keep import turtle, use module-level commands such as turtle.forward(...), put one turtle.done() at the end, save, and run the shown command in a terminal from this unit directory. Use left for shape turns.

Exercise 1: Courtyard Square

A park planner needs a square outline for a small courtyard.

Specification: Complete assets/ex1_square.py. Set n = 4, side = 62, angle = 360 / n, and the pen color to "royalblue". Use for corner in range(n). On each trip, trace one courtyard edge with turtle.forward(side), then face the next edge with turtle.left(angle). Add a comment that explains those two jobs.

Run it with:

assets/ex1_square.py

Check yourself: A royal-blue square with 4 sides of 62 steps, a 90-degree turn at each corner, 4 pen-down moves, and ends where it started: yes.

Real program

The real program reads the side length and the colour with input(), then draws the same picture.

How this is checked: You check this one yourself, against the list below. The turtle drawing is checked from the moves your program makes.

The site cannot check this one. Run your program, then tick each item below when your work does it.

Check your work

For parents and teachers: report a problem

Exercise 2: Trail-Sign Triangle

A trail sign uses a bold triangular border that must meet cleanly at all three corners.

Specification: Complete assets/ex2_triangle.py. Set n = 3, side = 74, angle = 360 / n, and the pen color to "forestgreen". Use a loop variable named corner. Draw one side and turn left once per loop trip. Remember that the turtle uses the outside angle, not the 60-degree inside angle.

Run it with:

assets/ex2_triangle.py

Check yourself: A forest-green triangle with 3 sides of 74 steps, a 120-degree turn at each corner, 3 pen-down moves, and ends where it started: yes.

Real program

The real program reads the side length and the colour with input(), then draws the same picture.

How this is checked: You check this one yourself, against the list below. The turtle drawing is checked from the moves your program makes.

The site cannot check this one. Run your program, then tick each item below when your work does it.

Check your work

For parents and teachers: report a problem

Exercise 3: Festival Pentagon

A festival badge needs five equal edges and a thicker colored outline.

Specification: Complete assets/ex3_pentagon.py. Set n = 5, side = 68, angle = 360 / n, the pen color to "orchid", and the pen size to 4. Use for side_number in range(n) and draw one side per trip. Add a comment that names the shape.

Run it with:

assets/ex3_pentagon.py

Check yourself: An orchid pentagon with 5 sides of 68 steps, a 72-degree turn at each corner, 5 pen-down moves, and ends where it started: yes.

Real program

The real program reads the side length, the colour, and the pen width with input(), then draws the same picture.

How this is checked: You check this one yourself, against the list below. The turtle drawing is checked from the moves your program makes.

The site cannot check this one. Run your program, then tick each item below when your work does it.

Check your work

For parents and teachers: report a problem

Exercise 4: Decimal-Turn Heptagon

A seven-sided game token tests whether the turtle can turn by a decimal and still close its path.

Specification: Complete assets/ex4_heptagon.py. Set n = 7, side = 57, angle = 360 / n, and the pen color to "darkorange". Use for corner in range(n). Add a comment saying that angle is a float and that all seven turns total 360 degrees. Do not replace / with a rounded number. Before you run the script, write down angle = 360 / 7 and predict what that expression equals. Keep print(angle) after the assignment so the terminal can check your prediction.

Run it with:

assets/ex4_heptagon.py

Check yourself: A dark-orange heptagon with 7 sides of 57 steps, the decimal angle printed in the terminal, a total turn of 360 degrees, and ends where it started: yes.

Real program

The real program reads the number of sides, the side length, and the colour with input(), then draws the same picture.

How this is checked: You check this one yourself, against the list below. The turtle drawing is checked from the moves your program makes.

The site cannot check this one. Run your program, then tick each item below when your work does it.

Check your work

For parents and teachers: report a problem

Exercise 5: Move, Then Mark

A map symbol must begin 39 steps away from the turtle's original position, without drawing a road to it.

Specification: Complete assets/ex5_travel_octagon.py. First lift the pen, move forward 39 steps, and lower the pen. Then set n = 8, side = 44, angle = 360 / n, and the pen color to "crimson". Use for corner in range(n) to draw the octagon.

Run it with:

assets/ex5_travel_octagon.py

Check yourself: A crimson octagon with 8 sides of 44 steps and a 45-degree turn after each side, following one invisible 39-step travel move. The octagon uses exactly 8 pen-down moves and ends where it started: yes.

Real program

The real program reads the travel distance, the number of sides, the side length, and the colour with input(), then draws the same picture.

How this is checked: You check this one yourself, against the list below. The turtle drawing is checked from the moves your program makes.

The site cannot check this one. Run your program, then tick each item below when your work does it.

Check your work

For parents and teachers: report a problem

Exercise 6: Nine-Hexagon Wheel

A tile artist arranges nine hexagons around a center point to make a wheel. One loop completes the current tile; the other advances the whole design.

Specification: Complete assets/ex6_shape_ring.py. Set n = 6, side = 41, angle = 360 / n, shape_count = 9, turn_between_shapes = 360 / shape_count, and the pen color to "turquoise". Use outer variable shape and inner variable corner. Finish the inner loop before turning left by turn_between_shapes. Give each loop its own comment that describes its role in the wheel.

Run it with:

assets/ex6_shape_ring.py

Check yourself: A turquoise ring of 9 hexagons with 6 sides of 41 steps each, 9 * 6 = 54 pen-down moves, a 40-degree turn between shapes, and ends where it started: yes.

Real program

The real program reads the number of sides, the side length, the number of shapes, and the colour with input(), then draws the same picture.

How this is checked: You check this one yourself, against the list below. The turtle drawing is checked from the moves your program makes.

The site cannot check this one. Run your program, then tick each item below when your work does it.

Check your work

For parents and teachers: report a problem

Exercise 7: Growing Radar Spiral

A radar display grows each new arm by the same amount, so the line winds outward instead of closing. Turning a little more than 90 degrees—92 degrees here—rotates each square-like corner slightly, so the path winds outward instead of stacking on its earlier lines.

Specification: Complete assets/ex7_growing_spiral.py. Set side = 11, step = 6, move_count = 14, and the pen color to "maroon". Use for side_number in range(move_count). Each trip moves forward by side, turns left 92 degrees, and updates the accumulator with side = side + step. Keep print(side) after the loop so the terminal shows the finished accumulator.

Run it with:

assets/ex7_growing_spiral.py

Check yourself: A maroon growing spiral with 14 pen-down moves; the first move is 11 steps, the final drawn move is 89 steps, the terminal prints 95, and the spiral does not return to its start.

Real program

The real program reads the starting side length, the growth step, the number of moves, and the colour with input(), then draws the same picture.

How this is checked: You check this one yourself, against the list below. The turtle drawing is checked from the moves your program makes.

The site cannot check this one. Run your program, then tick each item below when your work does it.

Check your work

For parents and teachers: report a problem

Exercise 8: Row of Squares

A mural needs four separate square outlines in a row.

Specification: Complete assets/ex8_row_of_squares.py. Use nested loops: the inner loop draws one square. After each square, including the fourth, lift the pen, move forward by travel, and lower the pen. After all four, lift the pen and move backward(240) to the start. Keep the final heading.

Worked sample — given values:

squares = 4
side = 40
travel = 60

Expected drawing and output: Four side-40 squares in a row; four invisible 60-step travels; the turtle returns to its starting position and heading.

Run it with:

assets/ex8_row_of_squares.py

Real program

The real program reads the number of squares, the side length, and the travel distance with input(), then draws the same picture.

How this is checked: You check this one yourself, against the list below. The turtle drawing is checked from the moves your program makes.

The site cannot check this one. Run your program, then tick each item below when your work does it.

Check your work

For parents and teachers: report a problem

Exercise 9: Dashed Line

A map route uses twelve visible dashes separated by twelve blank gaps.

Specification: Complete assets/ex9_dashed_line.py. Use for i in range(24). When i % 2 == 0, lower the pen, move 10 steps, and increase dashes by 1. On the other trips, lift the pen and move 10 steps. Print Dashes: 12.

Worked sample — given values:

segments = 24
step = 10

Expected drawing and output: Twelve drawn 10-step dashes and twelve invisible 10-step gaps; Dashes: 12.

Run it with:

assets/ex9_dashed_line.py

Real program

The real program reads the number of segments and the step length with input(), then draws the same picture.

How this is checked: You check this one yourself, against the list below. The turtle drawing is checked from the moves your program makes.

The site cannot check this one. Run your program, then tick each item below when your work does it.

Check your work

For parents and teachers: report a problem

Exercise 10: More Practice: Color-Alternating Ring

A badge repeats eight squares around one center in a red, blue, green cycle.

Specification: Complete assets/ex10_color_alternating_ring.py. Use nested loops. Before each square, choose pencolor with if/elif/else on i % 3: 0 is red, 1 is blue, otherwise green. After drawing each square, turn left 45 degrees, add 45 to turned, and add 1 to count. Print the two exact lines.

Worked sample — given values:

squares = 8
side = 40
turned = 0
count = 0

Expected drawing and output: Eight side-40 squares; Turned: 360 and Squares: 8.

Run it with:

assets/ex10_color_alternating_ring.py

Real program

The real program reads the number of squares and the side length with input(), then draws the same picture.

How this is checked: You check this one yourself, against the list below. The turtle drawing is checked from the moves your program makes.

The site cannot check this one. Run your program, then tick each item below when your work does it.

Check your work

For parents and teachers: report a problem

Exercise 11: More Practice: Growing Squares

Five squares share one corner and grow by the same amount.

Specification: Complete assets/ex11_growing_squares.py. Draw five squares sharing a corner. After each square, update with side = side + 20 (required), and increase drawn by 1. Print Squares: 5.

Worked sample — given values:

side = 20
drawn = 0

Expected drawing and output: Five closed squares with sides 20, 40, 60, 80, 100; Squares: 5.

Run it with:

assets/ex11_growing_squares.py

Real program

The real program reads the number of squares, the starting side length, and the growth amount with input(), then draws the same picture.

How this is checked: You check this one yourself, against the list below. The turtle drawing is checked from the moves your program makes.

The site cannot check this one. Run your program, then tick each item below when your work does it.

Check your work

For parents and teachers: report a problem

Exercise 12: More Practice: Seven-Point Star

A seven-point emblem connects every third point and must close cleanly.

Specification: Complete assets/ex12_seven_point_star.py. Use for point in range(points) and turn left by 3 * 360 / 7 after each stroke. Keep true division; do not round the turn to 154 degrees, which leaves a 2-degree gap.

Worked sample — given values:

points = 7
side = 90

Expected drawing and output: Seven 90-step strokes, each followed by a turn of 3 * 360 / 7 degrees; the path closes.

Run it with:

assets/ex12_seven_point_star.py

Real program

The real program reads the number of points and the side length with input(), then draws the same picture.

How this is checked: You check this one yourself, against the list below. The turtle drawing is checked from the moves your program makes.

The site cannot check this one. Run your program, then tick each item below when your work does it.

Check your work

For parents and teachers: report a problem

Exercise 13: More Practice: Fix the Misspelled Command

A square script stops because one turtle command is misspelled.

Specification: Complete assets/ex13_fix_misspelled_command.py. Read the broken code below and its exact error. Replace the placeholder with correct turtle.forward calls and draw a closed side-50 square with four 90-degree turns.

Broken code (do not run):

import turtle
turtle.foward(50)
AttributeError: module 'turtle' has no attribute 'foward'

Worked sample — given values:

side = 50

Expected drawing and output: A closed square of side 50 after the spelling is repaired.

Run it with:

assets/ex13_fix_misspelled_command.py

How this is checked: You check this one yourself, against the list below. The turtle drawing is checked from the moves your program makes.

The site cannot check this one. Run your program, then tick each item below when your work does it.

Check your work

For parents and teachers: report a problem

Exercise 14: More Practice: Fix the Missing Import

A triangle script uses turtle before bringing its tools into the program.

Specification: Complete assets/ex14_fix_missing_import.py. Read the broken code below and its exact error. Keep the starter’s import turtle at the top, then replace its placeholder with a closed side-70 triangle with 360 / 3 turns.

Broken code (do not run):

turtle.forward(70)
NameError: name 'turtle' is not defined

Worked sample — given values:

side = 70

Expected drawing and output: A closed triangle of side 70 after the missing import is repaired.

Run it with:

assets/ex14_fix_missing_import.py

How this is checked: You check this one yourself, against the list below. The turtle drawing is checked from the moves your program makes.

The site cannot check this one. Run your program, then tick each item below when your work does it.

Check your work

For parents and teachers: report a problem

Exercise 15: More Practice: Fix the Indentation

A pentagon loop cannot start because its body is not indented.

Specification: Complete assets/ex15_fix_indentation.py. Read the broken code below and its exact error. Replace the placeholder with a correctly indented loop that draws five side-60 edges with turns of 360 / 5.

Broken code (do not run):

import turtle
for corner in range(5):
turtle.forward(60)
IndentationError: expected an indented block after 'for' statement on line 2

Worked sample — given values:

side = 60
n = 5

Expected drawing and output: A closed pentagon of side 60 after the loop body is indented.

Run it with:

assets/ex15_fix_indentation.py

How this is checked: You check this one yourself, against the list below. The turtle drawing is checked from the moves your program makes.

The site cannot check this one. Run your program, then tick each item below when your work does it.

Check your work

For parents and teachers: report a problem

Exercise 16: Five-Point Star

  • Challenge

A stage logo crosses the center instead of tracing the outside of a regular pentagon. That path turns through two full turns.

Specification: Complete assets/ex16_five_point_star.py. Set n = 5, side = 96, angle = 720 / n, the pen color to "goldenrod", and the pen size to 3. Use for point in range(n) to draw one star stroke and turn left by angle. Add a comment explaining why the numerator is 720.

Run it with:

assets/ex16_five_point_star.py

Check yourself: A goldenrod five-point star with 5 strokes of 96 steps, a 144-degree turn after each stroke, a total turn of 720 degrees, and ends where it started: yes.

Real program

The real program reads the number of points, the side length, the colour, and the pen width with input(), then draws the same picture.

How this is checked: You check this one yourself, against the list below. The turtle drawing is checked from the moves your program makes.

The site cannot check this one. Run your program, then tick each item below when your work does it.

Check your work

For parents and teachers: report a problem

Exercise 17: The Eight-Degree Gap

  • Challenge

A teammate suggests using a whole-number shortcut for an eleven-sided outline. Your job is to compare that prediction with the honest polygon rule.

Specification: Complete assets/ex17_floor_division_gap.py as the correct comparison shape: set n = 11, side = 34, angle = 360 / n, and the pen color to "magenta". Use for corner in range(n) and turn left by angle. Keep true division in the asset. The honest angle is about 32.727 degrees, so its 11 turns total 360 degrees and the shape closes.

What do you think turtle.left(360 // 11) would draw? Explain why the 8-degree gap matters.

Your answer: ___

Run the correct comparison with:

assets/ex17_floor_division_gap.py

Check yourself: The script draws a magenta regular eleven-sided shape with 11 sides of 34 steps, a total turn of 360 degrees, and ends where it started: yes. Write your shortcut prediction above then run your program and compare its drawing and output with this description.

Real program

The real program reads the number of sides, the side length, and the colour with input(), then draws the same picture.

How this is checked: You check this one yourself, against the list below. The turtle drawing is checked from the moves your program makes.

The site cannot check this one. Run your program, then tick each item below when your work does it.

Check your work

For parents and teachers: report a problem

Exercise 18: Grid of Squares

  • Challenge

A tile board has three rows of three square outlines.

Specification: Complete assets/ex18_grid_of_squares.py. Use nested row, column, and side loops. Travel 45 steps between square starts with the pen lifted. After each row, use a pen-up return path to the row start, then move 45 steps to the next row; after the final row, return all the way to the original start. Count each square with squares = squares + 1 and print Squares: 9.

Worked sample — given values:

rows = 3
columns = 3
side = 30
travel = 45
squares = 0

Expected drawing and output: Nine side-30 squares in a 3 by 3 grid; Squares: 9; the turtle returns to the start and original heading.

Run it with:

assets/ex18_grid_of_squares.py

Real program

The real program reads the number of rows, the number of columns, the side length, and the travel distance with input(), then draws the same picture.

How this is checked: You check this one yourself, against the list below. The turtle drawing is checked from the moves your program makes.

The site cannot check this one. Run your program, then tick each item below when your work does it.

Check your work

For parents and teachers: report a problem

Back to Turtle Geometry