-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexercise_04_4.py
More file actions
74 lines (56 loc) · 2.24 KB
/
exercise_04_4.py
File metadata and controls
74 lines (56 loc) · 2.24 KB
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 jupyturtle import make_turtle, forward, left
def parallelogram(length, height, angle):
for i in range(2): # the loop is for the 2 pairs of sides
forward(length)
left(angle)
forward(height)
left(180 - angle) # the angle between the sides is 180 - angle
def perfect_rectangle(length):
height = length / 2 # the height is half of the length
angle = 90 # the angle between the sides is 90 degrees, on the parallelogram function, the angle is 180 - 90 = 90 degrees, so it will be a rectangle
parallelogram(length, height, angle) #the function is called with the length, height and angle values of perfect_rectangle()
def perfect_rhombus(length):
height = length
angle = 60 # the angle between the sides is 60 degrees, on the parallelogram function, the angle is 180 - 60 = 120 degrees, so it will be a rhombus
parallelogram(length, height, angle)
"""
if you want to make via input (rectangle(length=x, heigth=y, angle=z))
just put parallelogram(length, heigth, angle)
"""
# To make the drawn equal to the book
from jupyturtle import right, penup, pendown
def jump(length):
penup()
forward(length)
pendown()
def make_draws(length, height, angle): # change the function because now we will have a parallelogram shape
for i in range(2):
forward(length)
left(angle)
forward(height)
left(180 - angle)
def perfect_rectangle(length): # same thing
angle = 90
height = length / 2
make_draws(length, height, angle)
def rhombus(length): # same thing
angle = 60
height = length
make_draws(length, height, angle)
def parallelogram2(length): # we will fuse the rectangle with the rhombus to make a parallelogram
angle = 60 # angle of the rhombus
length_double = length * 2 # to have the same length as the rectangle we need to double, if not it will be a rhombus
height = length
make_draws(length_double, height, angle)
make_turtle()
# to start the drawn from the left
left(180)
jump(125)
right(180)
# to make the drawn aligned the values need to be this
perfect_rectangle(60)
jump(80)
rhombus(35)
jump (70)
parallelogram2(35)
# i dint make an automatic function to calculate because some of the things needed to do this are further in the book