Extend it:
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:
- 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. - Change the colours to draw a different flag
This is the easiest challenge: just change the values of the constants on lines 5-7
- 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!
Page 1: Intro
Page 2: The theory: learn what you need to know as fast as possible.
Page 3: Try it: try out and adapt some working python code snippets.
Page 4: Debug it: Learn how to find and fix common mistakes.
Page 5: Extend it: Choose a project idea to use your newfound python skills.
Trackbacks/Pingbacks