Lesson 21: Turtle in corners

posted May 31, 2019, 8:00 AM by Attila Lengyel
import turtle
import time
import random

t = turtle.Turtle()

def draw(x,y, delay, s):
t.clear()
t.penup()
t.goto(x,y)
t.pendown()
t.speed(s)
for x in range(0,3):
t.forward(50)
t.left(120)
time.sleep(delay)

time.sleep(2)
draw(0,0,3, 5)
for x in range(0,10):
time.sleep(1)
corner = random.randint(1,4)
if corner == 1:
draw(200,200,0,0)
elif corner == 2:
draw(-200, 200,0,0)
elif corner == 3:
draw(-200, -200,0,0)
else:
draw(200, -200,0,0)
time.sleep(2)
draw(0,0,3)

Comments