CODE KALEIDOSCOPE

Creative Code. Colourful Thinking.

Lesson 2

Lesson 2 of 8

Lesson 2 - Variables and Interactive Art

Use variables to control colour, size and movement in Turtle artwork.

Do Now — 5 mins Theory — 10 mins I Do — 5 mins We Do — 10 mins You Do — 20 mins Plenary — 5 mins

Lesson Journey

Use these stages to move from reading code to creating your own version.

  1. Predict
  2. Run
  3. Investigate
  4. Modify
  5. Make

Learning Aim

To use variables to store values that control Turtle artwork.

Defined End Point

By the end of this lesson, you will be able to use variables and values to control the size, colour and output of a Turtle artwork.

Key Vocabulary

variable value assignment size

Do Now

Guess the Variable

size = 50
colour = "blue"
repeats = 12
  1. Which variable controls the size?
  2. Which variable stores text?
  3. Which variable might control symmetry?
  4. What might happen if repeats becomes 24?

Stretch: Write your own variable.

Retrieval Practice

  • What does sequence mean?
  • Which Turtle command moves forward?
  • Why does command order matter?

Theory

Read the code and predict what will change if the value of size changes.

Read the code first. Do not run it yet.

from turtle import *

size = 80
pencolor("purple")
circle(size)

Prediction question

What do you think the variable size controls?

I Do

Watch the Demonstration

Watch how variables are used to control the Turtle output before typing the code yourself.

Type this code into Mu Editor and run it.

from turtle import *

size = 80
colour = "purple"
thickness = 4

pencolor(colour)
pensize(thickness)
circle(size)

right(90)
circle(size)

Typing the code yourself helps build Python fluency and debugging skills.

We Do

Find the lines that store values and connect them to the artwork.

Size

Which line controls the circle size?

Colour

Which line controls the pen colour?

Thickness

Which line controls the pen thickness?

You Do

Change one variable at a time and test the output after each change.

Change colour
Change pen size
Change shape size
Alter repeat values

Workbook Activity

Create a simple interactive artwork by choosing variables for colour, size and pen thickness.

Bronze

Change the colour and size variables.

Silver

Add a second shape using the same variables.

Gold

Create a pattern using at least three variables.

WAGOLL

Example code and output.

Use the example to connect the Python instructions with the visual result.

Example code

from turtle import *

size = 80
colour = "purple"
thickness = 4

pencolor(colour)
pensize(thickness)
circle(size)

right(90)
circle(size)

Example Output

This WAGOLL uses named variables so the design can be changed without rewriting every command.

Plenary

Explain what you learned and identify the next improvement you would make.

Extension task

Add a variable called turn_angle and use it to rotate your artwork.

Plenary question

Why is it useful to store values in variables?

Lesson Hub ←  Previous Next  →