CODEKALEIDOSCOPE

Creative Code. Colourful Thinking.

Lesson 3

Lesson 3 of 8

Lesson 3 - Selection and Interactive Drawing

Use selection to make Turtle programs respond to choices.

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 selection so a program can choose between different outcomes.

Defined End Point

By the end of this lesson, you will be able to create a drawing that uses if, elif and else to respond to different choices.

Key Vocabulary

selectionconditionifelse

Do Now

What Happens Next?

if colour == "blue":
    circle(50)
else:
    square(50)
  1. What shape will be drawn if colour is blue?
  2. What shape will be drawn if colour is red?
  3. What does if mean?
  4. Why is selection useful?

Stretch: Think of a real-life example of selection.

Retrieval Practice

  • What is a variable?
  • What does a value control?
  • How can changing one number change the output?

Theory

Predict which colour the turtle will use when the choice is set to flower.

Read the code first. Do not run it yet.

choice = "flower"

if choice == "flower":
    pencolor("pink")
else:
    pencolor("blue")

Prediction question

Which branch of the selection will run, and why?

I Do

Watch the Demonstration

Watch how selection chooses one drawing rule from more than one option.

Type this code into Mu Editor and run it.

from turtle import *

choice = "flower"

if choice == "flower":
    pencolor("pink")
    circle(50)
else:
    pencolor("blue")
    forward(100)

done()

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

We Do

Trace the condition and identify what happens when it is true or false.

Condition

Which line asks the question?

True path

Which commands run when the condition is true?

False path

Which commands run after else?

You Do

Change the choice value and test how the output changes.

Change choice
Change colours
Change shape size
Add another branch

Workbook Activity

Create a tiny choice-based drawing program.

Bronze

Choose between two colours.

Silver

Choose between two shapes.

Gold

Create an interactive drawing choice with three outcomes.

WAGOLL

Example code and output.

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

Example code

from turtle import *

choice = "flower"

if choice == "flower":
    pencolor("pink")
    circle(50)
else:
    pencolor("blue")
    forward(100)

done()

Example Output

This WAGOLL uses selection to make a clear choice and produce the matching Turtle output.

Plenary

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

Extension task

Add another choice and create a third visual outcome.

Plenary question

How is selection similar to making a choice in Scratch?

Lesson Hub←  PreviousNext  →