Extend it:

Make your code more efficient
Optimisation: Make your code more efficient

For this challenge you need to get creative as well as efficient to see how much you can get python to draw in lesson than 10s.

The code below measures how long the python code takes to run and displays the number of seconds since the program started. See how much you can draw in less than 10s by optimising the code as much as possible!

Challenges:

Use an image search to find some abstract art and try to draw it with python turtle

Use the timer in the code to see if you can make all your code run in less than 10s

Hint: you can use t.speed(0) to speed up drawing with turtle graphics

See if you can work through each of these challenges:

 
  1. Use a for loop

    The self marking test might not measure the drawing time correctly for turtle graphics so you’ll have to use the timings displayed on screen

  2. Use a while loop

    Hint: A syntax error prevents the code from running

  3. Define a procedure

    Hint: Use functions or procedures to avoid having to write the same lines of code multiple times

There are two more challenges which you’ll find when the tests run on your code. These aren’t anything to do with optimisation but you can use the t.color, t.begin_fill and t.end_fill methods to pass these tests by adding your own splashes of colour.

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.