-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmoooood.py
More file actions
61 lines (44 loc) · 986 Bytes
/
moooood.py
File metadata and controls
61 lines (44 loc) · 986 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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# the code with the mistake:
# it should return yellow star but it returns grey
mood = "happy"
import turtle
riley = turtle.Turtle()
riley.width(5)
if mood == "happy":
riley.color("yellow")
if mood == "sad":
riley.color("blue")
else:
riley.color("gray")
for side in range(5):
riley.forward(100)
riley.right(144)
# Here's the solution that uses nesting:
mood = "happy"
import turtle
riley = turtle.Turtle()
riley.width(5)
if mood == "happy":
riley.color("yellow")
else:
if mood == "sad":
riley.color("blue")
else:
riley.color("gray")
for side in range(5):
riley.forward(100)
riley.right(144)
# And here's the solution that uses elif:
mood = "happy"
import turtle
riley = turtle.Turtle()
riley.width(5)
if mood == "happy":
riley.color("yellow")
elif mood == "sad":
riley.color("blue")
else:
riley.color("gray")
for side in range(5):
riley.forward(100)
riley.right(144)