Learning Aim
To use different data types to control creative program output.
Defined End Point
By the end of this lesson, you will be able to use data types and random values to create controlled variation in generative artwork.

Creative Code. Colourful Thinking.
Lesson 5
Use numbers and strings as creative ingredients for generative Turtle artwork.
Use these stages to move from reading code to creating your own version.
To use different data types to control creative program output.
By the end of this lesson, you will be able to use data types and random values to create controlled variation in generative artwork.
Sort the Data
12
"blue"
50
"teal"
100
"flower"
36
"circle"
Whole numbers
Text in quotation marks
Stretch: What might randint(1, 10) do?
Predict which values are numbers and which values are text.
Read the code first. Do not run it yet.
colour = "green"
size = 60
pencolor(colour)
circle(size)
Why does "green" need quotation marks, but 60 does not?
Watch how data values become creative choices in Turtle artwork.
Type this code into Mu Editor and run it.
from turtle import *
from random import choice
colours = ["cyan", "magenta", "yellow", "purple"]
size = 40
speed(0)
for i in range(16):
pencolor(choice(colours))
circle(size)
right(22)
done()
Typing the code yourself helps build Python fluency and debugging skills.
Identify how different data types affect the design.
Which values are written in quotation marks?
Which values control size or repeats?
How does the colours list create variation?
Modify one data value at a time and test the result.
Create a generative artwork using numbers, strings and a list of colours.
Change the list of colours.
Change the size and repeat values.
Add random choices for shape size or turn angle.
Example code and output.
Use the example to connect the Python instructions with the visual result.
Example code
from turtle import *
from random import choice
colours = ["cyan", "magenta", "yellow", "purple"]
size = 40
speed(0)
for i in range(16):
pencolor(choice(colours))
circle(size)
right(22)
done()
This WAGOLL uses data values to create controlled generative variation.
Explain what you learned and identify the next improvement you would make.
Add another list and use it to vary pen size or circle size.
How can data make artwork feel generative?