-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunctions.py
More file actions
532 lines (500 loc) · 17.3 KB
/
Copy pathfunctions.py
File metadata and controls
532 lines (500 loc) · 17.3 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
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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
from termcolor import colored
import math
def Add(x, y):
return x + y
def Sub(x, y):
return x - y
def Mul(x, y):
return x * y
def Div(x, y):
return x / y
def Deg(x, y):
return x ** y
def Calculations(choice_Selected):
if choice_Selected == '+':
while True:
x = input('Enter first number\n===>')
try:
x = int(x)
except:
print('Please use numeric digits.')
continue
break
while True:
y = input('Enter second number\n===>')
try:
y = int(y)
except:
print('Please use numeric digits.')
continue
break
print(colored("====> ", 'red') + colored( str(Add(x, y)),"yellow"))
if choice_Selected == '-':
while True:
x = input('Enter first number\n===>')
try:
x = int(x)
except:
print('Please use numeric digits.')
continue
break
while True:
y = input('Enter second number\n===>')
try:
y = int(y)
except:
print('Please use numeric digits.')
continue
break
print(colored("====> ", 'red') + colored( str(Sub(x, y)),"yellow"))
if choice_Selected == '*':
while True:
x = input('Enter first number\n===>')
try:
x = int(x)
except:
print('Please use numeric digits.')
continue
break
while True:
y = input('Enter second number\n===>')
try:
y = int(y)
except:
print('Please use numeric digits.')
continue
break
print(colored("====> ", 'red') + colored( str(Mul(x, y)),"yellow"))
if choice_Selected == '/':
while True:
x = input('Enter first number\n===>')
try:
x = int(x)
except:
print('Please use numeric digits.')
continue
break
while True:
y = input('Enter second number\n===>')
try:
y = int(y)
except:
print('Please use numeric digits.')
continue
break
print(colored("====> ", 'red') + colored( str(Div(x, y)),"yellow"))
if choice_Selected == '**':
while True:
x = input('Enter first number\n===>')
try:
x = int(x)
except:
print('Please use numeric digits.')
continue
break
while True:
y = input('Enter Degree of 1st number\n===>')
try:
y = int(y)
except:
print('Please use numeric digits.')
continue
break
print(colored("====> ", 'red') + colored( str(Deg(x, y)),"yellow"))
if choice_Selected == 'x' or choice_Selected == 'X':
exit
def perimeter_Circle(radius):
print(colored("====> ", 'red') + colored( str(radius*2*3.1415) + "cm","yellow"))
def perimeter_Square(Side):
print(colored("====> ", 'red') + colored( str(Side*4) + "cm","yellow"))
def perimeter_Rectangle(Length, Width):
print(colored("====> ", 'red') + colored( str(2*(Length + Width)) + "cm","yellow"))
def perimeter_Parallelogram(side1, side2):
print(colored("====> ", 'red') + colored( str(2*(side1+side2)) + "cm","yellow"))
def perimeter_Triangle(side1, side2, side3):
print(colored("====> ", 'red') + colored( str(side1 + side2 + side3) + "cm","yellow"))
def perimeter_Regular_n_polygon(Number_of_Sides, Side):
print(colored("====> ", 'red') + colored( str(Number_of_Sides * Side) + "cm","yellow"))
def perimeter_Trapezium(a, b, c, d):
print(colored("====> ", 'red') + colored( str(a + b + c + d) + "cm", "yellow"))
def Perimeter(shape):
if shape == '1':
while True:
Radius = input("Enter the length of the Radius of the circle in cm\n====>")
try:
Radius = int(Radius)
except:
print('Please use numeric digits.')
continue
break
perimeter_Circle(Radius)
if shape == '2':
while True:
Side = input("Enter the length of the Side of square in cm\n====>")
try:
Side = int(Side)
except:
print('Please use numeric digits.')
continue
break
perimeter_Square(Side)
if shape == '3':
while True:
Length = input("Enter the length of Rectangle in cm\n====>")
try:
Length = int(Length)
except:
print('Please use numeric digits.')
continue
break
while True:
Width = input("Enter the Width of Rectangle in cm\n====>")
try:
Width = int(Width)
except:
print('Please use numeric digits.')
continue
break
perimeter_Rectangle(Length, Width)
if shape == '4':
while True:
Side1 = input("Enter the length of first side in cm\n====>")
try:
Side1 = int(Side1)
except:
print('Please use numeric digits.')
continue
break
while True:
Side2 = input("Enter the length of side adjacent to the first side in cm\n====>")
try:
Side2 = int(Side2)
except:
print('Please use numeric digits.')
continue
break
perimeter_Parallelogram(Side1, Side2)
if shape == '5':
while True:
Side1 = input("Enter the length of first side of the triangle in cm\n====>")
try:
Side1 = int(Side1)
except:
print('Please use numeric digits.')
continue
break
while True:
Side2 = input("Enter the length of second side of the triangle in cm\n====>")
try:
Side2 = int(Side2)
except:
print('Please use numeric digits.')
continue
break
while True:
Side3 = input("Enter the length of third side of the triangle in cm\n====>")
try:
Side3 = int(Side3)
except:
print('Please use numeric digits.')
continue
break
perimeter_Triangle(Side1, Side2, Side3)
if shape == '6':
while True:
Number_of_Sides = input("Enter the number of sides of the polygon \n====>")
try:
Number_of_Sides = int(Number_of_Sides)
except:
print('Please use numeric digits.')
continue
if Number_of_Sides < 3:
print('Minimum sides of the polygon is 3')
continue
break
while True:
Side = input("Enter the length of the side of the polygon in cm\n====>")
try:
Side = int(Side)
except:
print('Please use numeric digits.')
continue
break
perimeter_Regular_n_polygon(Number_of_Sides, Side)
if shape == '7':
while True:
a = input("Enter the length of first side of the Trapezium in cm \n====>")
try:
a = int(a)
except:
print('Please use numeric digits.')
continue
break
while True:
b = input("Enter the length of the second side of the Trapezium in cm\n====>")
try:
b = int(b)
except:
print('Please use numeric digits.')
continue
break
while True:
c = input("Enter the length of the third side of the Trapezium in cm\n====>")
try:
c = int(c)
except:
print('Please use numeric digits.')
continue
break
while True:
d = input("Enter the length of the fourth side of the Trapezium in cm\n====>")
try:
d = int(d)
except:
print('Please use numeric digits.')
continue
break
perimeter_Trapezium(a, b, c, d)
def Area_Circle(radius):
print(colored("====> ", 'red') + colored( str(3.1415 * radius**2) + "cm","yellow"))
def Area_Square(Side):
print(colored("====> ", 'red') + colored( str(Side**2) + "cm²","yellow"))
def Area_Rectangle(Length, Width):
print(colored("====> ", 'red') + colored( str(Length * Width) + "cm²","yellow"))
def Area_Parallelogram(Base, Height):
print(colored("====> ", 'red') + colored( str(Base * Height) + "cm²","yellow"))
def Area_Triangle(Base, Height):
print(colored("====> ", 'red') + colored( str(Base * Height /2) + "cm²","yellow"))
def Area_Regular_n_polygon(Number_of_Sides, Side):
x = 3.1415/ Number_of_Sides
angle = 1/math.tan(x)
print(colored("====> ", 'red') + colored( str(round(1/4*Number_of_Sides* (Side**2)*angle,2)) + "cm²","yellow"))
def Area_Trapezium(a, b, Height):
print(colored("====> ", 'red') + colored( str(Height*(a + b)/2) + "cm²", "yellow"))
def Area(shape):
if shape == '1':
while True:
Radius = input("Enter the length of the Radius of the circle in cm\n====>")
try:
Radius = int(Radius)
except:
print('Please use numeric digits.')
continue
break
Area_Circle(Radius)
if shape == '2':
while True:
Side = input("Enter the length of the Side of square in cm\n====>")
try:
Side = int(Side)
except:
print('Please use numeric digits.')
continue
break
perimeter_Square(Side)
if shape == '3':
while True:
Length = input("Enter the length of Rectangle in cm\n====>")
try:
Length = int(Length)
except:
print('Please use numeric digits.')
continue
break
while True:
Width = input("Enter the Width of Rectangle in cm\n====>")
try:
Width = int(Width)
except:
print('Please use numeric digits.')
continue
break
perimeter_Rectangle(Length, Width)
if shape == '4':
while True:
Base = input("Enter the length of Base of the parallelogram in cm\n====>")
try:
Base = int(Base)
except:
print('Please use numeric digits.')
continue
break
while True:
Height = input("Enter the length of Height of the parallelogram in cm\n====>")
try:
Height = int(Height)
except:
print('Please use numeric digits.')
continue
break
Area_Parallelogram(Base, Height)
if shape == '5':
while True:
Base = input("Enter the Base of the triangle in cm\n====>")
try:
Base = int(Base)
except:
print('Please use numeric digits.')
continue
break
while True:
Height = input("Enter the Height of the triangle in cm\n====>")
try:
Height = int(Height)
except:
print('Please use numeric digits.')
continue
break
Area_Triangle(Base, Height)
if shape == '6':
while True:
Number_of_Sides = input("Enter the number of sides of the polygon \n====>")
try:
Number_of_Sides = int(Number_of_Sides)
except:
print('Please use numeric digits.')
continue
if Number_of_Sides < 3:
print('Minimum sides of the polygon is 3')
continue
break
while True:
Side = input("Enter the length of the side of the polygon in cm\n====>")
try:
Side = int(Side)
except:
print('Please use numeric digits.')
continue
break
Area_Regular_n_polygon(Number_of_Sides, Side)
if shape == '7':
while True:
a = input("Enter the length of first base of the Trapezium in cm \n====>")
try:
a = int(a)
except:
print('Please use numeric digits.')
continue
break
while True:
b = input("Enter the length of the second base of the Trapezium in cm\n====>")
try:
b = int(b)
except:
print('Please use numeric digits.')
continue
break
while True:
Height = input("Enter the length of the Height of the Trapezium in cm\n====>")
try:
Height = int(Height)
except:
print('Please use numeric digits.')
continue
break
Area_Trapezium(a, b, Height)
def Volume_Cube(Side):
print(colored("====> ", 'red') + colored( str(Side**3) + "cm³","yellow"))
def Volume_Cuboid(Side1, Side2, Side3):
print(colored("====> ", 'red') + colored( str(Side1 * Side2 * Side3) + "cm³","yellow"))
def Volume_Sphere(Radius):
print(colored("====> ", 'red') + colored( str(4/3*(3.1415 * Radius**3)) + "cm³","yellow"))
def Volume_HemiSphere(Radius):
print(colored("====> ", 'red') + colored( str(2/3*(3.1415 * Radius**3)) + "cm³","yellow"))
def Volume_Cone(Radius, Height):
print(colored("====> ", 'red') + colored( str(1/3*(3.1415 * Radius**2 * Height)) + "cm³","yellow"))
def Volume_Cylinder(Radius, Height):
print(colored("====> ", 'red') + colored( str(3.1415 * Radius**2 * Height) + "cm³","yellow"))
def Volume(Shape):
if Shape == '1':
while True:
Side = input("Enter the length of the Side of the Cube in cm\n====>")
try:
Side = int(Side)
except:
print('Please use numeric digits.')
continue
break
Volume_Cube(Side)
if Shape == '2':
while True:
Side1 = input("Enter the length of the First Side of the Cuboid in cm\n====>")
try:
Side1 = int(Side1)
except:
print('Please use numeric digits.')
continue
break
while True:
Side2 = input("Enter the length of the Second Side of the Cuboid in cm\n====>")
try:
Side2 = int(Side2)
except:
print('Please use numeric digits.')
continue
break
while True:
Side3 = input("Enter the length of the Third Side of the Cuboid in cm\n====>")
try:
Side3 = int(Side3)
except:
print('Please use numeric digits.')
continue
break
Volume_Cuboid(Side1, Side2, Side3)
if Shape == '3':
while True:
Radius = input("Enter the length of the Radius of the Sphere in cm\n====>")
try:
Radius = int(Radius)
except:
print('Please use numeric digits.')
continue
break
Volume_Sphere(Radius)
if Shape == '4':
while True:
Radius = input("Enter the length of the Radius of the Hemi Sphere in cm\n====>")
try:
Radius = int(Radius)
except:
print('Please use numeric digits.')
continue
break
Volume_HemiSphere(Radius)
if Shape == '5':
while True:
Radius = input("Enter the length of the Radius of the Cone in cm\n====>")
try:
Radius = int(Radius)
except:
print('Please use numeric digits.')
continue
break
while True:
Height = input("Enter the length of the Height of the Cone in cm\n====>")
try:
Height = int(Height)
except:
print('Please use numeric digits.')
continue
break
Volume_Cone(Radius, Height)
if Shape == '6':
while True:
Radius = input("Enter the length of the Radius of the Cylinder in cm\n====>")
try:
Radius = int(Radius)
except:
print('Please use numeric digits.')
continue
break
while True:
Height = input("Enter the length of the Height of the Cylinder in cm\n====>")
try:
Height = int(Height)
except:
print('Please use numeric digits.')
continue
break
Volume_Cylinder(Radius, Height)