-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhello_turtle.py
73 lines (66 loc) · 2.22 KB
/
hello_turtle.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
#############################################################################
# FILE : hello_turtle.py
# WRITER : Lior Paz, lioraryepaz, 206240996
# EXERCISE : intro2cs ex1 2017-2018
# DESCRIPTION : a program that Draws a bed of flowers using turtle functions
#############################################################################
# The next line imports the turtle module into the program.
# We will use the different turtle commands in this program in order to draw.
import turtle
def draw_petal():
# These next lines define drawing of a Petal.
turtle.forward(30)
turtle.right(45)
turtle.forward(30)
turtle.right(135)
turtle.forward(30)
turtle.right(45)
turtle.forward(30)
turtle.right(135)
# The next line ends this function definition.
return
def draw_flower():
# These next lines define drawing of a Flower combined out of 4 petals & stem
# This function is based on the previous defined petal func.
turtle.left(45)
draw_petal()
turtle.left(90)
draw_petal()
turtle.left(90)
draw_petal()
turtle.left(90)
draw_petal()
turtle.left(135)
turtle.forward(150)
# The next line ends this function definition.
return
def draw_flower_advanced():
# These next lines define drawing of a flower and move the turtle pen head in
# order to prepare for the drawing of the next flower.
# This function is based on the previous defined flower func.
draw_flower()
turtle.right(90)
turtle.up()
turtle.forward(150)
turtle.right(90)
turtle.forward(150)
turtle.left(90)
turtle.down()
# The next line ends this function definition
return
def draw_flower_bed():
# These next lines define drawing of 3 fully drawn flowers.
# This function is based on the previous defined flower_advanced func.
turtle.up()
turtle.forward(200)
turtle.left(180)
turtle.down()
draw_flower_advanced()
draw_flower_advanced()
draw_flower_advanced()
# The next line ends this function definition.
return
#The next line run the previously defined function which draws bed of flowers
draw_flower_bed()
# The next command will pause the program and prevent it from closing.
turtle.done()