← Reference

Final challenge: Catch the turtle: cheat sheet

Python functions and events · In any playground, open Reference to copy these.

random number

Pick a random whole number between two values.

import random

n = random.randint(1, 10)

ontimer

Run a function again after a number of milliseconds. A function can start its own timer.

def tick():
    forward(5)
    ontimer(tick, 50)

tick()
mainloop()