Skip to content

Commit 7390111

Browse files
authored
Add files via upload
1 parent f3dabfe commit 7390111

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed

turtle race.py

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
from turtle import Turtle
2+
from random import randint
3+
4+
aman=Turtle()
5+
aman.color('blue')
6+
aman.shape('turtle')
7+
aman.penup()
8+
aman.goto(-180,100)
9+
aman.pendown()
10+
11+
swati=Turtle()
12+
swati.color('red')
13+
swati.shape('turtle')
14+
swati.penup()
15+
swati.goto(-180,70)
16+
swati.pendown()
17+
18+
ram=Turtle()
19+
ram.color('green')
20+
ram.shape('turtle')
21+
ram.penup()
22+
ram.goto(-180,40)
23+
ram.pendown()
24+
25+
krishna=Turtle()
26+
krishna.color('dark blue')
27+
krishna.shape('turtle')
28+
krishna.penup()
29+
krishna.goto(-180,10)
30+
krishna.pendown()
31+
32+
for movement in range(100):
33+
aman.forward(randint(1,5))
34+
swati.forward(randint(1, 5))
35+
ram.forward(randint(1, 5))
36+
krishna.forward(randint(1, 5))
37+
if aman.position() > (swati.position() and ram.position()and krishna.position()):
38+
print(("Aman won the race"))
39+
elif swati.position()>(aman.position() and ram.position() and krishna.position()):
40+
print("swati won the race")
41+
elif ram.position()> (aman.position() and swati.position() and krishna.position()):
42+
print("ram won the race")
43+
else:
44+
print("Krishna won the race")
45+
46+
47+
48+
input(" ...")

0 commit comments

Comments
 (0)