05: Python: Naming Conventions

Extend it:

Use variables and constants with sensible names
Python naming conventions: Use variables and constants with sensible names

We introduced some code that drew shapes in the Try It section on page 3. Your challenges involve experimenting with and extending some similar code to draw some flags for different countries.

Here’s a starting point for drawing a French flag.

The drawing code imports a module called turtle. This is named after a programmable robot that looked a bit like a turtle that could move around the floor drawing lines and shapes.

Challenges:

  1. Draw the final section of the French flag (a red rectangle)

    The code you need to add to the bottom of the program will look a little bit like the code on lines 41-55.
    Think about the direction you need the turtle to move and how far it should go.

  2. Change the colours to draw a different flag

    This is the easiest challenge: just change the values of the constants on lines 5-7

  3. Add a new constant that lets you change the size of the flag

    You’ll need to think of a suitable name for your constant, set a value at the start of the code and then use the constant’s name instead of some of the numbers on lines 31 to the end.

There’s so many different ways to complete these challenges that I can’t think of a reliable way to automatically give you a score. Have fun!

Leave a Reply