forked from Devansh-Gutti/python-simple-calculator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
MyMath.py
62 lines (53 loc) · 1.77 KB
/
MyMath.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
from tkinter import messagebox
# myArea takes 5 arguments and gives us area of 2D shapes
def myArea(name, length, breadth, height, radius):
name = name.lower()
if name == "rectangle":
return(length*breadth)
elif name == "square":
return(length**2)
elif name == "triangle":
return(0.5*breadth*height)
elif name == "circle":
return(3.14*radius**2)
else:
return(-1)
# myvolume takes 5 args and gives volume of 3D shapes
def myvolume(name, length, breadth, height, radius):
name = name.lower()
if name == "sphere":
return(4/3*radius**3)
elif name == "cube":
return(length**3)
elif name == "cone":
return(0.33*radius**2*height)
elif name == "cuboid":
return(length*breadth*height)
elif name == "cylinder":
return(3.14*radius**2*height)
else:
return(-1)
# mycondition returns complementary angle for angles <=90 deg, supplementary angle for angles <= 180 deg
# error is returned in other cases
# mycondition also checks pythagoras theorem for 3 numbers and tells whether it is a py triplet or not
def mycondition(condition, a, b, c, angle):
if condition == "Pythagorean Triplet Checker":
if a**2+b**2 == c**2:
return(1)
else:
return(2)
if condition == "Complimentary&Supplementary Angles":
if angle <= 90:
com = 90-angle
sup = 180-angle
elif angle <= 180:
sup = 180-angle
com = "error"
else:
sup = com = "error"
comsuplist = [com, sup]
com1 = comsuplist[0]
sup1 = comsuplist[1]
messagebox.showinfo("Complementary Angle", com1)
messagebox.showinfo("Supplementary Angle", sup1)
return comsuplist