-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTurtleRandomWalk
More file actions
36 lines (25 loc) · 763 Bytes
/
Copy pathTurtleRandomWalk
File metadata and controls
36 lines (25 loc) · 763 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
import random
import turtle as t
t.colormode(255)
dodo = t.Turtle()
#colors = ["Red", "Blue", "Green", "Black", "Purple", "Grey", "SeaGreen", "DarkOrchid", "IndianRed", "DeepSkyBlue"]
directions = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 120, 150, 160, 180, 270]
#we will give a random rgb value to it now
def random_color():
r = random.randint(0, 255)
g = random.randint(0, 255)
b = random.randint(0, 255)
random_color = (r, g, b)
return random_color
dodo.pensize(10)
dodo.speed('fastest')
dodo.penup()
dodo.right(90)
dodo.forward(200)
dodo.pendown()
for i in range(200):
#we are calling the method here
dodo.color(random_color())
dodo.forward(20)
dodo.setheading(random.choice(directions))
Screen().exitonclick()