-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgeometrical operations.py
159 lines (121 loc) · 3.75 KB
/
geometrical operations.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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
flag = True
while flag:
print("**** WELCOME TO GEOMETRICAL OPERATIONS ****")
print("1-) SQUARE")
print("2-) RECTANGLE")
print("3-) TRIANGLE")
print("4-) CIRCLE")
print("5-) EXIT")
print("*******************************************")
choice = int(input("Which geometric shape would you like to use? : "))
print("\n1")
if choice == 1:
side = int(input("enter the size of the square: "))
print("--- MENU ---")
print("1-) AREA")
print("2-) PERIMETER")
print("3-) MAIN MENU")
print("-------------",end="\n")
choice_s = int(input("What operation would you like to do? : "))
print("\n")
if choice_s == 1:
print(f"Area of the square: {side*side}")
print("\n")
if choice_s == 2:
print(f"Perimeter of the square: {side*4}")
print("\n")
if choice_s == 3:
continue
elif choice == 2:
l = int(input("enter length for rectangle: "))
w = int(input("enter width for rectangle: "))
print("--- MENU ---")
print("1-) AREA")
print("2-) PERIMETER")
print("3-) MAIN MENU")
print("-------------",end="\n")
choice_r = int(input("What operation would you like to do? : "))
print("\n")
if choice_r == 1:
print(f"Area of the rectangle: {l*w}")
print("\n")
if choice_r == 2:
print(f"Perimeter of the rectangle: {2*(l+w)}")
print("\n")
if choice_r == 3:
continue
elif choice == 3:
print("--- MENU ---")
print("1-) TRIANGLE WITH DIFFERENT SIDES")
print("2-) RIGHT TRIANGLE")
print("3-) MAIN MENU")
print("-------------",end="\n")
choice_t = int(input("Which geometric shape would you like to use? : "))
print("\n")
if choice_t == 1:
print("--- MENU ---")
print("1-) AREA")
print("2-) PERIMETER")
print("3-) MAIN MENU")
print("-------------",end="\n")
choice_t1 = int(input("What operation would you like to do? : "))
print("\n")
if choice_t1 == 1:
print("Enter the sides of the triangle with spaces next to each other:")
a,b,c = map(int,input().split())
u = (a+b+c)/2
area = "%.2f"%(u*(u-a)*(u-b)*(u-c))**0.5
print(f"Area of the triangle with different side: {area}")
print("\n")
if choice_t1 == 2:
print("Enter the sides of the triangle with spaces next to each other:")
a,b,c = map(int,input().split())
print(f"Perimeter of the triangle with different sides: {a+b+c}")
print("\n")
if choice_t1 == 3:
continue
if choice_t == 2:
print("--- MENU ---")
print("1-) AREA")
print("2-) PERIMETER")
print("3-) MAIN MENU")
print("-------------",end="\n")
choice_t2 = int(input("What operation would you like to do? : "))
print("\n")
if choice_t2 == 1:
height = int(input("enter for the height of the right triangle: "))
base = int(input("enter for the base of the right triangle: "))
print(f"Area of the right triangle: {(height*base)/2}")
print("\n")
if choice_t2 == 2:
print("Enter the sides of the triangle with spaces next to each other:")
a,b,c = map(int,input().split())
print(f"Perimeter of the right triangle: {a+b+c}")
print("\n")
if choice_t2 == 3:
continue
elif choice == 4:
print("--- MENU ---")
print("1-) AREA")
print("2-) CIRCUMFERENCE")
print("3-) MAIN MENU")
print("-------------",end="\n")
choice_c = int(input("What operation would you like to do? : "))
print("\n")
if choice_c == 1:
pi = 3.14
radius = int(input("enter for radius: "))
area = "%.2f"%(pi*(radius**2))
print(f"Area of the circle: {area}")
print("\n")
if choice_c == 2:
pi = 3.14
radius = int(input("enter for radius: "))
circumference = "%.2f"%(2*pi*radius)
print(f"Circumference of the circle: {circumference}")
print("\n")
if choice_c == 3:
continue
elif choice == 5:
print("PROGRAM IS TERMINATED")
flag = False