Introduction to Python - Using Colour

Posted on 09-10-19 in Computing

This post is part 6 of the Introduction to Programming" series
Introduction to Python - Lesson One

Introduction to programming using Python and Turtle

Introduction to Python - Lesson Two

Continuing our introduction to Python using Turtle

Introduction to Python - Lesson Three

Looking at loops and conditionals in more detail

Introduction to Python - Lesson Four

Further exploration of Turtle and an introduction to colour

Introduction to Python using Turtle : A Review

A brief review of the first part of this Turtle course

Introduction to Python - Using Colour

This is an aside / extension material for students who get ahead

In this article we will cover :

  1. How to change the colour of the turtle's pen
  2. How to fill shapes
  3. What colours a computer can understand

Review

You will need to be able to :

  1. Draw simple shapes using Turtle
embedded video, no alt provided

In this video we have changed the colour using tl.color('red'). Notice the American spelling! Here's one way to accomplish this in code

import turtle as tl

tl.width(10)

for colour in ('red', 'green', 'yellow', 'purple'):
    tl.color(colour)
    tl.forward(200)
    tl.left(90)

tl.exitonclick()

TODO

  1. Which colours are allowed? Can we produce something nice for the kids to use?
  2. How to specify colours as 0 -> 1
  3. Exercises based on this (include an alternating colour example, ie using a = not a
  4. How to do fill
  5. Exercises and freetime