-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathchristmas-tree.py
74 lines (63 loc) · 1.26 KB
/
christmas-tree.py
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
from turtle import *
#writing speed
speed(0)
penup()
goto(0, -250)
pendown()
#change the bg color
color("lightskyblue")
begin_fill()
circle(250)
end_fill()
# Tree Trunk
penup()
goto(-15, -50)
pendown()
color("brown")
begin_fill()
for i in range(2):
forward(30)
right(90)
forward(40)
right(90)
end_fill()
# Set the start position and the inital tree width
y = -50
width = 240
height = 25
while width > 20:
width = width - 30 # Make the tree get smaller as it goes up in height
x = 0 - width / 2 # Set the starting x-value of each level of the tree
color("green")
penup()
goto(x, y)
pendown()
begin_fill()
for i in range(2):
forward(width)
left(90)
forward(height)
left(90)
end_fill()
y = y + height # Keep drawing the levels of the tree higher than the previous
# Star
penup()
goto(-15, 150)
pendown()
color("yellow")
begin_fill()
for i in range(5):
forward(30)
right(144)
end_fill()
# Message
penup()
goto(-130, -150)
color("red")
write("MERRY CHRISTMAS", font=("Arial", 20, "bold"))
penup()
goto(-130, -200)
color("black")
write("Coded By Sumalya Chatterjee", font=("Arial", 10))
hideturtle()
done()