Skip to content

Instantly share code, notes, and snippets.

@tvdsluijs
Last active February 18, 2019 07:58
Show Gist options
  • Save tvdsluijs/2e7ad26fd7f4bad7d59ce2dff168f215 to your computer and use it in GitHub Desktop.
Save tvdsluijs/2e7ad26fd7f4bad7d59ce2dff168f215 to your computer and use it in GitHub Desktop.
turtle race
# code for a course Im doing
# https://www.futurelearn.com/courses/object-oriented-principles/6
from turtle import Turtle
from random import randint
def myturtles(color, start, end):
tur = Turtle()
tur.color(color)
tur.shape('turtle')
tur.penup()
tur.goto(start, end)
tur.pendown()
return tur
mytur = []
mytur.append(myturtles('red', -160, 100))
mytur.append(myturtles('blue', -160, 70))
mytur.append(myturtles('purple', -160, 40))
mytur.append(myturtles('pink', -160, 10))
for movement in range(100):
for tur in mytur:
tur.forward(randint(1,5))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment