import turtle
from turtle import Turtle
import random
turtle.title('Turtle rance')
turtle.bgcolor('grey')
turtle.color('white')
turtle.penup()
turtle.goto(-100, 200)
turtle.write('Turtle race', font=('Arial', 30, 'bold'))
turtle.goto(-400, -200)
turtle.color('brown')
size = [800, 120, 800, 120]
turtle.speed(100)
turtle.begin_fill()
for i in range(4):
turtle.forward(size[i])
turtle.right(90)
turtle.end_fill()
turtle.shape('square')
turtle.color('dark green')
for i in range(10):
turtle.goto(300, 150 - (i*30))
turtle.stamp()
for i in range(10):
turtle.goto(310, 140 - (i*30))
turtle.stamp()
t1 = Turtle()
t1.penup()
t1.goto(-200, 0)
t1.shape('turtle')
t1.color('yellow')
t2 = Turtle()
t2.penup()
t2.goto(-200, 50)
t2.shape('turtle')
t2.color('blue')
t3 = Turtle()
t3.penup()
t3.goto(-200, 100)
t3.shape('turtle')
t3.color('black')
t4 = Turtle()
t4.penup()
t4.goto(-200, -50)
t4.shape('turtle')
t4.color('red')
d1 = 0
d2 = 0
d3 = 0
d4 = 0
for i in range(200):
ran1 = random.randint(1, 25)
ran2 = random.randint(1, 25)
ran3 = random.randint(1, 25)
ran4 = random.randint(1, 25)
t1.forward(ran1)
d1 += ran1
t2.forward(ran2)
d2 += ran2
t3.forward(ran3)
d3 += ran3
t4.forward(ran4)
d4 += ran4
if d1 >= 499 or d2 >= 499 or d3 >= 499 or d4 >= 499:
distance = {d1:'yellow', d2:'blue', d3:'black', d4:'red'}
turtle.goto(-350, 290)
turtle.write('Final result', font=('Arial', 20, 'bold'))
one = max(distance.keys())
turtle.goto(-350, 260)
turtle.write('1:{}'.format(distance[one]), font=('Arial', 13))
del distance[one]
two = max(distance.keys())
turtle.goto(-350, 240)
turtle.write('2:{}'.format(distance[two]), font=('Arial', 13))
del distance[two]
three = max(distance.keys())
turtle.goto(-350, 220)
turtle.write('3:{}'.format(distance[three]), font=('Arial', 13))
del distance[three]
four = max(distance.keys())
turtle.goto(-350, 200)
turtle.write('4:{}'.format(distance[four]), font=('Arial', 13))
break
turtle.hideturtle()
turtle.done()