-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathturtlesWoComments.py
More file actions
40 lines (31 loc) · 1010 Bytes
/
Copy pathturtlesWoComments.py
File metadata and controls
40 lines (31 loc) · 1010 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import turtle
import random
wn = turtle.Screen()
wn.bgcolor('lightblue')
wn.title("Turtle Race")
lance = turtle.Turtle()
andy = turtle.Turtle()
lance.color('red')
andy.color('blue')
lance.shape('turtle')
andy.shape('turtle')
andy.up()
lance.up()
andy.goto(-100, 20)
lance.goto(-100, -20)
start = turtle.Turtle() # OPTIONAL-
start.hideturtle()
for i in range(150):
andyDistance = random.randrange(1, 5)
lanceDistance = random.randrange(1, 5)
andy.forward(andyDistance)
lance.forward(lanceDistance)
andyTotalDistance = andyTotalDistance + andyDistance
lanceTotalDistance = lanceTotalDistance + lanceDistance
for eachInt in range(145):
if andyTotalDistance > lanceTotalDistance:
start.write("Andy is the winner!", move=False, align="center", font=("Arial", 25, "normal"))
elif lanceTotalDistance > andyTotalDistance:
start.write("Lance is the winner!", move=False, align="center", font=("Arial", 25, "normal"))
else: print("Tie Game")
wn.exitonclick()