-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcalculator.py
1253 lines (1167 loc) · 51 KB
/
calculator.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
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
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
import time
import os
import pyperclip
history_file = "history.txt"
current_time = time.asctime()
clearHis = ["clshis","CLSHIS","Clshis","cLshis","CLShis","ClsHis","CLsHIs","clsHIS","clsHis"]
def clear_terminal():
if os.name == "nt":
os.system("cls")
else:
os.system("clear")
def clear_history():
with open(history_file, 'w') as clearFile:
clearFile.write("")
print("History file cleared...!")
print("Wait 2 seconds..")
time.sleep(2)
process()
def process():
clear_terminal()
print("""
\u001b[31;1m _ _ _ \u001b[32;1m ______ _
\u001b[31;1m| | | | |_ \u001b[32;1m / _____) | |
\u001b[31;1m| | | | | |_ ____ ____ \u001b[32;1m | / ____| |
\u001b[31;1m| | | | | _) / ___) _ | \u001b[32;1m | | / _ | |
\u001b[31;1m| |___| | | |__| | ( ( | | \u001b[32;1m | \____( ( | | |
\u001b[31;1m\_______|_|\___)_| \_||_| \u001b[32;1m \______)_||_|_|
\u001b[31;1m \u001b[33;1mBY SAVITHU_S3\u001b[0m""")
print("")
print("\u001b[31;1mUltra \u001b[32;1mCal\u001b[0m🧮 - \u001b[34;1mVersion 2.6\u001b[0m")
print("-------------------------------------------------")
print("| |")
print(">>> https://github.com/savithu-s3 <<<")
print("| |")
print(">>> [email protected] <<<")
print("| |")
print("-------------------------------------------------")
print("""
\u001b[34m=================================\u001b[0m
Area = 1
Perimeter & Circumference = 2
Volume = 3
\u001b[34m=================================\u001b[0m
Clear History = \u001b[33mclshis\u001b[0m
Exit = \u001b[31mExit\u001b[0m
""")
type = input("What type of calculator do you need (Enter a number from above) or enter the command : ")
yes = ["Yes","yes","Y","y"]
def jump_process():
time.sleep(2)
input("Press any key to continue...")
process()
def exit_process():
print("Exiting in 3 seconds")
time.sleep(3)
exit()
# |----------------AREA SUBFUNCTIONS---------------|
# <<<<<<<<<<<<<<< Shapes >>>>>>>>>>>>>>>
# 1 Square
def square_area():
clear_terminal()
side_len = input("Enter the side length : ")
if side_len.isnumeric():
side_len = int(side_len)
sq_ar = side_len*side_len
sq_ar = str(sq_ar)
with open(history_file, 'r') as historyFileR:
readF = historyFileR.read()
with open(history_file, 'w') as historyFileW:
historyFileW.write(readF + "\n" + current_time + " [Area of square : " + sq_ar + "]")
print("\u001b[34m---------------------------------------------------------\u001b[0m")
print(">>> Area of square : \u001b[33;1m" + sq_ar + "\u001b[0m <<<")
print("\u001b[34m---------------------------------------------------------\u001b[0m")
copy = input("Do you need to copy the answer : ")
if copy in yes:
pyperclip.copy(sq_ar)
print("Answer Copied...!!!")
jump_process()
else:
jump_process()
else:
print("Please enter only numbers!")
square_area()
# 2 Rectangle
def rectangle_area():
clear_terminal()
rect_len = input("Enter length : ")
rect_bread = input("Enter breadth : ")
if (rect_len.isnumeric()) and (rect_bread.isnumeric()):
rect_len = int(rect_len)
rect_bread = int(rect_bread)
rec_ar = rect_bread*rect_len
rec_ar = str(rec_ar)
with open(history_file, 'r') as historyFileR:
readF = historyFileR.read()
with open(history_file, 'w') as historyFileW:
historyFileW.write(readF + "\n" + current_time + " [Area of rectangle : " + rec_ar + "]")
print("\u001b[34m---------------------------------------------------------\u001b[0m")
print(">>> Area of rectangle : \u001b[33;1m" + rec_ar + "\u001b[0m <<<")
print("\u001b[34m---------------------------------------------------------\u001b[0m")
copy = input("Do you need to copy the answer : ")
if copy in yes:
pyperclip.copy(rec_ar)
print("Answer Copied...!!!")
jump_process()
else:
jump_process()
else:
print("Please enter only numbers!")
rectangle_area()
# 3 Circle
def circle_area():
clear_terminal()
print("""
\u001b[34m=================================\u001b[0m
Full Circle = 1
Semicircle = 2
Quarter circle = 3
Custom Angled Circle = 4
\u001b[34m=================================\u001b[0m
Clear History = \u001b[33mclshis\u001b[0m
Exit = \u001b[31mExit\u001b[0m
""")
circle_type = input("Enter the type of circle : ")
if circle_type == "1":
clear_terminal()
radius = input("Enter radius : ")
if radius.isnumeric():
radius = int(radius)
mul_o_sev = radius%7
pi = 3.14
if (mul_o_sev == 0):
pi = 22/7
cir_ar = pi*radius*radius
cir_ar = str(cir_ar)
with open(history_file, 'r') as historyFileR:
readF = historyFileR.read()
with open(history_file, 'w') as historyFileW:
historyFileW.write(readF + "\n" + current_time + " [Area of circle : " + cir_ar + "]")
print("\u001b[34m---------------------------------------------------------\u001b[0m")
print(">>> Area of circle : \u001b[33;1m" + cir_ar + "\u001b[0m <<<")
print("\u001b[34m---------------------------------------------------------\u001b[0m")
copy = input("Do you need to copy the answer : ")
if copy in yes:
pyperclip.copy(cir_ar)
print("Answer Copied...!!!")
jump_process()
else:
jump_process()
else:
print("Please enter only numbers!")
circle_area()
elif circle_type == "2":
clear_terminal()
radius = input("Enter radius : ")
if radius.isnumeric():
radius = int(radius)
mul_o_sev = radius%7
pi = 3.14
if (mul_o_sev == 0):
pi = 22/7
semicir_ar = (pi*radius*radius)/2
semicir_ar = str(semicir_ar)
with open(history_file, 'r') as historyFileR:
readF = historyFileR.read()
with open(history_file, 'w') as historyFileW:
historyFileW.write(readF + "\n" + current_time + " [Area of semicircle : " + semicir_ar + "]")
print("\u001b[34m---------------------------------------------------------\u001b[0m")
print(">>> Area of semicircle : \u001b[33;1m" + semicir_ar + "\u001b[0m <<<")
print("\u001b[34m---------------------------------------------------------\u001b[0m")
copy = input("Do you need to copy the answer : ")
if copy in yes:
pyperclip.copy(semicir_ar)
print("Answer Copied...!!!")
jump_process()
else:
jump_process()
else:
print("Please enter only numbers!")
circle_area()
elif circle_type == "3":
clear_terminal()
radius = input("Enter radius : ")
if radius.isnumeric():
radius = int(radius)
mul_o_sev = radius%7
pi = 3.14
if (mul_o_sev == 0):
pi = 22/7
quartcir_ar = (pi*radius*radius)/4
quartcir_ar = str(quartcir_ar)
with open(history_file, 'r') as historyFileR:
readF = historyFileR.read()
with open(history_file, 'w') as historyFileW:
historyFileW.write(readF + "\n" + current_time + " [Area of quarter circle : " + quartcir_ar + "]")
print("\u001b[34m---------------------------------------------------------\u001b[0m")
print(">>> Area of semicircle : \u001b[33;1m" + quartcir_ar + "\u001b[0m <<<")
print("\u001b[34m---------------------------------------------------------\u001b[0m")
copy = input("Do you need to copy the answer : ")
if copy in yes:
pyperclip.copy(quartcir_ar)
print("Answer Copied...!!!")
jump_process()
else:
jump_process()
else:
print("Please enter only numbers!")
circle_area()
elif circle_type == "4":
clear_terminal()
radius = input("Enter radius : ")
angle = input("Enter the angle of circle : ")
if (radius.isnumeric()) and (angle.isnumeric()):
radius = int(radius)
angle = int(angle)
mul_o_sev = radius%7
pi = 3.14
if (mul_o_sev == 0):
pi = 22/7
cir_ar = (angle/360)*(pi*radius*radius)
cir_ar = str(cir_ar)
with open(history_file, 'r') as historyFileR:
readF = historyFileR.read()
with open(history_file, 'w') as historyFileW:
historyFileW.write(readF + "\n" + current_time + " [Area of circle : " + cir_ar + "]")
print("\u001b[34m---------------------------------------------------------\u001b[0m")
print(">>> Area of circle : \u001b[33;1m" + cir_ar + "\u001b[0m <<<")
print("\u001b[34m---------------------------------------------------------\u001b[0m")
copy = input("Do you need to copy the answer : ")
if copy in yes:
pyperclip.copy(cir_ar)
print("Answer Copied...!!!")
jump_process()
else:
jump_process()
else:
print("Please enter only numbers!")
circle_area()
else:
print("Enter a correct value...!")
time.sleep(3)
circle_area()
# 4 Triangle
def triangle_area():
clear_terminal()
base = input("Enter base length : ")
height = input("Enter perpendicular height : ")
if (base.isnumeric()) and (height.isnumeric()):
base = int(base)
height = int(height)
tri_ar = (base*height)/2
tri_ar = str(tri_ar)
with open(history_file, 'r') as historyFileR:
readF = historyFileR.read()
with open(history_file, 'w') as historyFileW:
historyFileW.write(readF + "\n" + current_time + " [Area of triangle : " + tri_ar + "]")
print("\u001b[34m---------------------------------------------------------\u001b[0m")
print(">>> Area of triangle : \u001b[33;1m" + tri_ar + "\u001b[0m <<<")
print("\u001b[34m---------------------------------------------------------\u001b[0m")
copy = input("Do you need to copy the answer : ")
if copy in yes:
pyperclip.copy(tri_ar)
print("Answer Copied...!!!")
jump_process()
else:
jump_process()
else:
print("Please enter only numbers!")
triangle_area()
# 5 Hexagon
def hexagon_area():
clear_terminal()
hex_len = input("Enter length of a side : ")
if hex_len.isnumeric():
hex_len = int(hex_len)
hex_ar = ((3*(3**0.5))/2)*(hex_len**2)
hex_ar = round(hex_ar, 2)
hex_ar = str(hex_ar)
with open(history_file, 'r') as historyFileR:
readF = historyFileR.read()
with open(history_file, 'w') as historyFileW:
historyFileW.write(readF + "\n" + current_time + " [Area of hexagon : " + hex_ar + "]")
print("\u001b[34m---------------------------------------------------------\u001b[0m")
print(">>> Area of hexagon : \u001b[33;1m" + hex_ar + "\u001b[0m <<<")
print("\u001b[34m---------------------------------------------------------\u001b[0m")
copy = input("Do you need to copy the answer : ")
if copy in yes:
pyperclip.copy(hex_ar)
print("Answer Copied...!!!")
jump_process()
else:
jump_process()
else:
print("Please enter only numbers!")
hexagon_area()
# 6 Pentagon
def pentagon_area():
clear_terminal()
pen_len = input("Enter length of a side : ")
if pen_len.isnumeric():
pen_len = int(pen_len)
pen_ar = (1/4)*((5*(5+2*(5**0.5)))**0.5)*(pen_len**2)
pen_ar = round(pen_ar, 2)
pen_ar = str(pen_ar)
with open(history_file, 'r') as historyFileR:
readF = historyFileR.read()
with open(history_file, 'w') as historyFileW:
historyFileW.write(readF + "\n" + current_time + " [Area of pentagon : " + pen_ar + "]")
print("\u001b[34m---------------------------------------------------------\u001b[0m")
print(">>> Area of pentagon : \u001b[33;1m" + pen_ar + "\u001b[0m <<<")
print("\u001b[34m---------------------------------------------------------\u001b[0m")
copy = input("Do you need to copy the answer : ")
if copy in yes:
pyperclip.copy(pen_ar)
print("Answer Copied...!!!")
jump_process()
else:
jump_process()
else:
print("Please enter only numbers!")
pentagon_area()
# 7 Oval
def oval_area():
clear_terminal()
radius1 = input("Enter radius 1 : ")
radius2 = input("Enter radius 2 : ")
if (radius1.isnumeric()) and (radius2.isnumeric()):
radius1 = int(radius1)
radius2 = int(radius2)
pi = 3.14
oval_ar = pi*radius1*radius2
oval_ar = round(oval_ar, 2)
oval_ar = str(oval_ar)
with open(history_file, 'r') as historyFileR:
readF = historyFileR.read()
with open(history_file, 'w') as historyFileW:
historyFileW.write(readF + "\n" + current_time + " [Area of oval : " + oval_ar + "]")
print("\u001b[34m---------------------------------------------------------\u001b[0m")
print(">>> Area of oval : \u001b[33;1m" + oval_ar + "\u001b[0m <<<")
print("\u001b[34m---------------------------------------------------------\u001b[0m")
copy = input("Do you need to copy the answer : ")
if copy in yes:
pyperclip.copy(oval_ar)
print("Answer Copied...!!!")
jump_process()
else:
jump_process()
else:
print("Please enter only numbers!")
oval_area()
# AREA OF SHAPES - SELECTOR
def area_shapes():
clear_terminal()
print("""
\u001b[34m=================================\u001b[0m
----Area Of Shapes----
Square = 1
Rectangle = 2
Circle = 3
Triangle = 4
Oval = 5
Regualar Hexagon = 6
Regualar Pentagon = 7
\u001b[34m=================================\u001b[0m
Exit = Exit
""")
shape_area = input("Enter the number of a shape from above : ")
if (shape_area == "1"):
square_area()
elif (shape_area == "2"):
rectangle_area()
elif (shape_area == "3"):
circle_area()
elif (shape_area == "4"):
triangle_area()
elif (shape_area == "5"):
oval_area()
elif (shape_area == "6"):
hexagon_area()
elif (shape_area == "7"):
pentagon_area()
elif (shape_area == "Exit" or shape_area == "exit" or shape_area == "EXIT" or shape_area == "eXIT"):
exit_process()
else:
print("You entered an incorrect value")
area_shapes()
# <<<<<<<<<<<<<<< Solids >>>>>>>>>>>>>>>
# 1 Cube
def cube_area():
clear_terminal()
side_leng = input("Enter side Length : ")
if side_leng.isnumeric():
side_leng = int(side_leng)
cube_ar = (side_leng*side_leng)*6
cube_ar = str(cube_ar)
with open(history_file, 'r') as historyFileR:
readF = historyFileR.read()
with open(history_file, 'w') as historyFileW:
historyFileW.write(readF + "\n" + current_time + " [Area of cube : " + cube_ar + "]")
print("\u001b[34m---------------------------------------------------------\u001b[0m")
print(">>> Area of cube : \u001b[33;1m" + cube_ar + "\u001b[0m <<<")
print("\u001b[34m---------------------------------------------------------\u001b[0m")
copy = input("Do you need to copy the answer : ")
if copy in yes:
pyperclip.copy(cube_ar)
print("Answer Copied...!!!")
jump_process()
else:
jump_process()
else:
print("Please enter only numbers!")
cube_area()
# 2 Cuboid
def cuboid_area():
clear_terminal()
length = input("Enter side Length : ")
breadth = input("Enter Breadth : ")
height = input("Enter Height : ")
if (length.isnumeric()) and (breadth.isnumeric()) and (height.isnumeric()):
length = int(length)
breadth = int(breadth)
height = int(height)
cuboid_ar = ((length*height)*2) + ((breadth*height)*2) + ((length*breadth)*2)
cuboid_ar = str(cuboid_ar)
with open(history_file, 'r') as historyFileR:
readF = historyFileR.read()
with open(history_file, 'w') as historyFileW:
historyFileW.write(readF + "\n" + current_time + " [Area of cuboid : " + cuboid_ar + "]")
print("\u001b[34m---------------------------------------------------------\u001b[0m")
print(">>> Area of cuboid : \u001b[33;1m" + cuboid_ar + "\u001b[0m <<<")
print("\u001b[34m---------------------------------------------------------\u001b[0m")
copy = input("Do you need to copy the answer : ")
if copy in yes:
pyperclip.copy(cuboid_ar)
print("Answer Copied...!!!")
jump_process()
else:
jump_process()
else:
print("Please enter only numbers!")
cuboid_area()
# 3 Ball
def ball_area():
clear_terminal()
radius = input("Enter the radius : ")
if radius.isnumeric():
radius = int(radius)
mul_o_sev = radius%7
pi = 3.14
if (mul_o_sev == 0):
pi = 22/7
ball_ar = (4*pi*radius*radius)
ball_ar = str(ball_ar)
with open(history_file, 'r') as historyFileR:
readF = historyFileR.read()
with open(history_file, 'w') as historyFileW:
historyFileW.write(readF + "\n" + current_time + " [Area of ball : " + ball_ar + "]")
print("\u001b[34m---------------------------------------------------------\u001b[0m")
print(">>> Area of ball : \u001b[33;1m" + ball_ar + "\u001b[0m <<<")
print("\u001b[34m---------------------------------------------------------\u001b[0m")
copy = input("Do you need to copy the answer : ")
if copy in yes:
pyperclip.copy(ball_ar)
print("Answer Copied...!!!")
jump_process()
else:
jump_process()
else:
print("Please enter only numbers!")
ball_area()
# 4 Cylinder
def cylinder_area():
clear_terminal()
radius = input("Enter the radius of a circle : ")
height = input("Enter the height of the cylinder : ")
if (radius.isnumeric()) and (height.isnumeric()):
radius = int(radius)
height = int(height)
mul_o_sev = radius%7
pi = 3.14
if (mul_o_sev == 0):
pi = 22/7
circ_ar = (pi*radius*radius)*2
breadth = 2*pi*radius
cylinder_ar = (height*breadth) + circ_ar
cylinder_ar = str(cylinder_ar)
with open(history_file, 'r') as historyFileR:
readF = historyFileR.read()
with open(history_file, 'w') as historyFileW:
historyFileW.write(readF + "\n" + current_time + " [Area of cylinder : " + cylinder_ar + "]")
print("\u001b[34m---------------------------------------------------------\u001b[0m")
print(">>> Area of cylinder : \u001b[33;1m" + cylinder_ar + "\u001b[0m <<<")
print("\u001b[34m---------------------------------------------------------\u001b[0m")
copy = input("Do you need to copy the answer : ")
if copy in yes:
pyperclip.copy(cylinder_ar)
print("Answer Copied...!!!")
jump_process()
else:
jump_process()
else:
print("Please enter only numbers!")
cylinder_area()
# 5 Tetrahedron
def tetrahedron_area():
clear_terminal()
height = input("Enter the perpendicular height of a triangle : ")
base = input("Enter the base length of a triangle : ")
if (height.isnumeric()) and (base.isnumeric()):
height = int(height)
base = int(base)
tri_ar = (height*base)/2
tetra_ar = tri_ar*4
tetra_ar = str(tetra_ar)
with open(history_file, 'r') as historyFileR:
readF = historyFileR.read()
with open(history_file, 'w') as historyFileW:
historyFileW.write(readF + "\n" + current_time + " [Area of tetrahedron : " + tetra_ar + "]")
print("\u001b[34m---------------------------------------------------------\u001b[0m")
print(">>> Area of tetrahedron : \u001b[33;1m" + tetra_ar + "\u001b[0m <<<")
print("\u001b[34m---------------------------------------------------------\u001b[0m")
copy = input("Do you need to copy the answer : ")
if copy in yes:
pyperclip.copy(tetra_ar)
print("Answer Copied...!!!")
jump_process()
else:
jump_process()
else:
print("Please enter only numbers!")
tetrahedron_area()
# 6 Pyramid
def pyramid_area():
clear_terminal()
height = input("Enter the perpendicular height of a triangle : ")
base = input("Enter the base length of a triangle : ")
if (height.isnumeric()) and (base.isnumeric()):
height = int(height)
base = int(base)
tri_ar = ((height*base)/2)*4
pyr_ar = (base*base) + tri_ar
pyr_ar = str(pyr_ar)
with open(history_file, 'r') as historyFileR:
readF = historyFileR.read()
with open(history_file, 'w') as historyFileW:
historyFileW.write(readF + "\n" + current_time + " [Area of pyramid : " + pyr_ar + "]")
print("\u001b[34m---------------------------------------------------------\u001b[0m")
print(">>> Area of pyramid : \u001b[33;1m" + pyr_ar + "\u001b[0m <<<")
print("\u001b[34m---------------------------------------------------------\u001b[0m")
copy = input("Do you need to copy the answer : ")
if copy in yes:
pyperclip.copy(pyr_ar)
print("Answer Copied...!!!")
jump_process()
else:
jump_process()
else:
print("Please enter only numbers!")
pyramid_area()
# AREA OF SOLIDS - SELECTOR
def area_solids():
clear_terminal()
print("""
\u001b[34m=================================\u001b[0m
----Area Of Solids----
Cube = 1
Cuboid = 2
Ball = 3
Cylinder = 4
Tetrahedron = 5
Pyramid = 6
\u001b[34m=================================\u001b[0m
Exit = Exit
""")
solid_area = input("Enter the number of a solid from above : ")
if (solid_area == "1"):
cube_area()
elif (solid_area == "2"):
cuboid_area()
elif (solid_area == "3"):
ball_area()
elif (solid_area == "4"):
cylinder_area()
elif (solid_area == "5"):
tetrahedron_area()
elif (solid_area == "6"):
pyramid_area()
elif (solid_area == "Exit" or solid_area == "exit" or solid_area == "EXIT" or solid_area == "eXIT"):
exit_process()
else:
print("You entered an incorrect value")
area_solids()
# |---------------PERIMETER SUBFUNCTIONS---------------|
# 1 Square
def square_perimeter():
clear_terminal()
side_length = input("Enter side length : ")
if side_length.isnumeric():
side_length = int(side_length)
per_sq = side_length*4
per_sq = str(per_sq)
with open(history_file, 'r') as historyFileR:
readF = historyFileR.read()
with open(history_file, 'w') as historyFileW:
historyFileW.write(readF + "\n" + current_time + " [Perimeter of square : " + per_sq + "]")
print("\u001b[34m---------------------------------------------------------\u001b[0m")
print(">>> Perimeter of square : \u001b[33;1m" + per_sq + "\u001b[0m <<<")
print("\u001b[34m---------------------------------------------------------\u001b[0m")
copy = input("Do you need to copy the answer : ")
if copy in yes:
pyperclip.copy(per_sq)
print("Answer Copied...!!!")
jump_process()
else:
jump_process()
else:
print("Please enter only numbers!")
square_perimeter()
# 2 Rectangle
def rectangle_perimeter():
clear_terminal()
length = input("Enter the length : ")
breadth = input("Enter the breadth : ")
if (length.isnumeric()) and (breadth.isnumeric()):
length = int(length)
breadth = int(breadth)
per_rec = (length*2) + (breadth*2)
per_rec = str(per_rec)
with open(history_file, 'r') as historyFileR:
readF = historyFileR.read()
with open(history_file, 'w') as historyFileW:
historyFileW.write(readF + "\n" + current_time + " [Perimeter of rectangle : " + per_rec + "]")
print("\u001b[34m---------------------------------------------------------\u001b[0m")
print(">>> Perimeter of rectangle : \u001b[33;1m" + per_rec + "\u001b[0m <<<")
print("\u001b[34m---------------------------------------------------------\u001b[0m")
copy = input("Do you need to copy the answer : ")
if copy in yes:
pyperclip.copy(per_rec)
print("Answer Copied...!!!")
jump_process()
else:
jump_process()
else:
print("Please enter only numbers!")
rectangle_perimeter()
# 3 Circle
def circle_perimeter():
clear_terminal()
print("""
\u001b[34m=================================\u001b[0m
Full Circle = 1
Semicircle = 2
Quarter Circle = 3
Custom Angled Circle = 4
\u001b[34m=================================\u001b[0m
Clear History = \u001b[33mclshis\u001b[0m
Exit = \u001b[31mExit\u001b[0m
""")
circle_type = input("Enter the type of circle : ")
if circle_type == "1":
clear_terminal()
radius = input("Enter the radius : ")
if radius.isnumeric():
radius = int(radius)
mul_o_sev = radius%7
pi = 3.14
if (mul_o_sev == 0):
pi = 22/7
per_circ = (2*pi*radius)
per_circ = str(per_circ)
with open(history_file, 'r') as historyFileR:
readF = historyFileR.read()
with open(history_file, 'w') as historyFileW:
historyFileW.write(readF + "\n" + current_time + " [Circumference of circle : " + per_circ + "]")
print("\u001b[34m---------------------------------------------------------\u001b[0m")
print(">>> Circumference of circle : \u001b[33;1m" + per_circ + "\u001b[0m <<<")
print("\u001b[34m---------------------------------------------------------\u001b[0m")
copy = input("Do you need to copy the answer : ")
if copy in yes:
pyperclip.copy(per_circ)
print("Answer Copied...!!!")
jump_process()
else:
jump_process()
else:
print("Please enter only numbers!")
circle_perimeter()
elif circle_type == "2":
clear_terminal()
radius = input("Enter the radius : ")
if radius.isnumeric():
radius = int(radius)
mul_o_sev = radius%7
pi = 3.14
if (mul_o_sev == 0):
pi = 22/7
arc_circ = (pi*radius)
full_circ = arc_circ + (2*radius)
full_circ = str(full_circ)
arc_circ = str(arc_circ)
with open(history_file, 'r') as historyFileR:
readF = historyFileR.read()
with open(history_file, 'w') as historyFileW:
historyFileW.write(readF + "\n" + current_time + " [Perimeter of semicircle : " + full_circ + "]")
print("\u001b[34m---------------------------------------------------------\u001b[0m")
print(">>> Arc length of semicircle : \u001b[33;1m" + arc_circ + "\u001b[0m <<<")
print(">>> Perimeter of semicircle : \u001b[33;1m" + full_circ + "\u001b[0m <<<")
print("\u001b[34m---------------------------------------------------------\u001b[0m")
copy = input("Do you need to copy the answer : ")
if copy in yes:
pyperclip.copy("Arc Length : " + arc_circ + " , Perimeter : " + full_circ)
print("Answer Copied...!!!")
jump_process()
else:
jump_process()
else:
print("Please enter only numbers!")
circle_perimeter()
elif circle_type == "3":
clear_terminal()
radius = input("Enter the radius : ")
if radius.isnumeric():
radius = int(radius)
mul_o_sev = radius%7
pi = 3.14
if (mul_o_sev == 0):
pi = 22/7
arc_circ = (pi*radius)/2
full_circ = arc_circ + (2*radius)
full_circ = str(full_circ)
arc_circ = str(arc_circ)
with open(history_file, 'r') as historyFileR:
readF = historyFileR.read()
with open(history_file, 'w') as historyFileW:
historyFileW.write(readF + "\n" + current_time + " [Perimeter of quarter circle : " + full_circ + "]")
print("\u001b[34m---------------------------------------------------------\u001b[0m")
print(">>> Arc length of quarter circle : \u001b[33;1m" + arc_circ + "\u001b[0m <<<")
print(">>> Perimeter of quarter circle : \u001b[33;1m" + full_circ + "\u001b[0m <<<")
print("\u001b[34m---------------------------------------------------------\u001b[0m")
copy = input("Do you need to copy the answer : ")
if copy in yes:
pyperclip.copy("Arc Length : " + arc_circ + " , Perimeter : " + full_circ)
print("Answer Copied...!!!")
jump_process()
else:
jump_process()
else:
print("Please enter only numbers!")
circle_perimeter()
circle_area()
elif circle_type == "4":
clear_terminal()
radius = input("Enter the radius : ")
angle = input("Enter the angle of circle : ")
if radius.isnumeric() and (angle.isnumeric()):
radius = int(radius)
angle = int(angle)
mul_o_sev = radius%7
pi = 3.14
if (mul_o_sev == 0):
pi = 22/7
arc_circ = (angle/360)*(2*pi*radius)
full_circ = arc_circ + (2*radius)
full_circ = str(full_circ)
arc_circ = str(arc_circ)
with open(history_file, 'r') as historyFileR:
readF = historyFileR.read()
with open(history_file, 'w') as historyFileW:
historyFileW.write(readF + "\n" + current_time + " [Perimeter of " + str(angle) + "angled circle : " + full_circ + "]")
print("\u001b[34m---------------------------------------------------------\u001b[0m")
print(">>> Arc length of " + str(angle) + "angled circle : \u001b[33;1m" + arc_circ + "\u001b[0m <<<")
print(">>> Perimeter of " + str(angle) + "angled circle : \u001b[33;1m" + full_circ + "\u001b[0m <<<")
print("\u001b[34m---------------------------------------------------------\u001b[0m")
copy = input("Do you need to copy the answer : ")
if copy in yes:
pyperclip.copy("Arc Length : " + arc_circ + " , Perimeter : " + full_circ)
print("Answer Copied...!!!")
jump_process()
else:
jump_process()
else:
print("Please enter only numbers!")
circle_perimeter()
else:
print("Enter a correct value...!")
time.sleep(3)
circle_perimeter()
# 4 Oval
def oval_perimeter():
clear_terminal()
radius1 = input("Enter radius 1 : ")
radius2 = input("Enter radius 2 : ")
if (radius1.isnumeric()) and (radius2.isnumeric()):
radius1 = int(radius1)
radius2 = int(radius2)
pi = 3.14
per_oval = 2*pi*(((radius1**2 + radius2**2)/2)**0.5)
per_oval = round(per_oval, 2)
per_oval = str(per_oval)
with open(history_file, 'r') as historyFileR:
readF = historyFileR.read()
with open(history_file, 'w') as historyFileW:
historyFileW.write(readF + "\n" + current_time + " [Circumference of oval : " + per_oval + "]")
print("\u001b[34m---------------------------------------------------------\u001b[0m")
print(">>> Circumference of oval : \u001b[33;1m" + per_oval + "\u001b[0m <<<")
print("\u001b[34m---------------------------------------------------------\u001b[0m")
copy = input("Do you need to copy the answer : ")
if copy in yes:
pyperclip.copy(per_oval)
print("Answer Copied...!!!")
jump_process()
else:
jump_process()
else:
print("Please enter only numbers!")
oval_perimeter()
# 5 Equilateral Triangle
def triangle_perimeter():
clear_terminal()
side_length = input("Enter the side length : ")
if side_length.isnumeric():
side_length = int(side_length)
per_tri = side_length*3
per_tri = str(per_tri)
with open(history_file, 'r') as historyFileR:
readF = historyFileR.read()
with open(history_file, 'w') as historyFileW:
historyFileW.write(readF + "\n" + current_time + " [Perimeter of triangle : " + per_tri + "]")
print("\u001b[34m---------------------------------------------------------\u001b[0m")
print(">>> Perimeter of triangle : \u001b[33;1m" + per_tri + "\u001b[0m <<<")
print("\u001b[34m---------------------------------------------------------\u001b[0m")
copy = input("Do you need to copy the answer : ")
if copy in yes:
pyperclip.copy(per_tri)
print("Answer Copied...!!!")
jump_process()
else:
jump_process()
else:
print("Please enter only numbers!")
triangle_perimeter()
# 6 Regular Pentagon
def pentagon_perimeter():
clear_terminal()
side_length = input("Enter the side length : ")
if side_length.isnumeric():
side_length = int(side_length)
per_pent = side_length*5
per_pent = str(per_pent)
with open(history_file, 'r') as historyFileR:
readF = historyFileR.read()
with open(history_file, 'w') as historyFileW:
historyFileW.write(readF + "\n" + current_time + " [Perimeter of pentagon : " + per_pent + "]")
print("\u001b[34m---------------------------------------------------------\u001b[0m")
print(">>> Perimeter of pentagon : \u001b[33;1m" + per_pent + "\u001b[0m <<<")
print("\u001b[34m---------------------------------------------------------\u001b[0m")
copy = input("Do you need to copy the answer : ")
if copy in yes:
pyperclip.copy(per_pent)
print("Answer Copied...!!!")
jump_process()
else:
jump_process()
else:
print("Please enter only numbers!")
pentagon_perimeter()
# 7 Regular Hexagon
def hexagon_perimeter():
clear_terminal()
side_length = input("Enter the side length : ")
if side_length.isnumeric():
side_length = int(side_length)
per_hex = side_length*6
per_hex = str(per_hex)
with open(history_file, 'r') as historyFileR:
readF = historyFileR.read()
with open(history_file, 'w') as historyFileW:
historyFileW.write(readF + "\n" + current_time + " [Perimeter of hexagon : " + per_hex + "]")
print("\u001b[34m---------------------------------------------------------\u001b[0m")
print(">>> Perimeter of hexagon : \u001b[33;1m" + per_hex + "\u001b[0m <<<")
print("\u001b[34m---------------------------------------------------------\u001b[0m")
copy = input("Do you need to copy the answer : ")
if copy in yes:
pyperclip.copy(per_hex)
print("Answer Copied...!!!")
jump_process()
else:
jump_process()
else:
print("Please enter only numbers!")
hexagon_perimeter()
# |---------------VOLUME SUBFUNCTIONS---------------|
# 1 Cube
def cube_volume():
clear_terminal()
side_length = input("Enter the side length : ")
if side_length.isnumeric():
side_length = int(side_length)
vol_cube = side_length**3
vol_cube = str(vol_cube)
with open(history_file, 'r') as historyFileR:
readF = historyFileR.read()
with open(history_file, 'w') as historyFileW:
historyFileW.write(readF + "\n" + current_time + " [Volume of cube : " + vol_cube + "]")
print("\u001b[34m---------------------------------------------------------\u001b[0m")
print(">>> Volume of cube : \u001b[33;1m" + vol_cube + "\u001b[0m <<<")
print("\u001b[34m---------------------------------------------------------\u001b[0m")
copy = input("Do you need to copy the answer : ")
if copy in yes:
pyperclip.copy(vol_cube)
print("Answer Copied...!!!")
jump_process()
else:
jump_process()
else:
print("Please enter only numbers!")
cube_volume()
# 2 Cuboid
def cuboid_volume():
clear_terminal()
length = input("Enter the length : ")
breadth = input("Enter the breadth : ")
height = input("Enter the height : ")
if (length.isnumeric()) and (breadth.isnumeric()) and (height.isnumeric()):
length = int(length)
breadth = int(breadth)
height = int(height)
vol_cuboid = length*breadth*height
vol_cuboid = str(vol_cuboid)
with open(history_file, 'r') as historyFileR:
readF = historyFileR.read()
with open(history_file, 'w') as historyFileW:
historyFileW.write(readF + "\n" + current_time + " [Volume of cuboid : " + vol_cuboid + "]")
print("\u001b[34m---------------------------------------------------------\u001b[0m")
print(">>> Volume of cuboid : \u001b[33;1m" + vol_cuboid + "\u001b[0m <<<")
print("\u001b[34m---------------------------------------------------------\u001b[0m")
copy = input("Do you need to copy the answer : ")
if copy in yes:
pyperclip.copy(vol_cuboid)