-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmath.py
More file actions
126 lines (103 loc) · 2.9 KB
/
math.py
File metadata and controls
126 lines (103 loc) · 2.9 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
def categories():
print("Choices: ")
print("'a' Normal math")
print("'b' Misc.")
def misc_categories():
print("Choices: ")
print("'a' month calculator")
def choices():
print("Choices:")
print("'a' subtract")
print("'b' divide")
print("'c' multiply")
print("'d' odd or even number")
print("'e' perimeters")
print("'f' addition")
print("'g' averages")
print("")
print("Categories:")
print("'1' for misc.")
categories()
category = str(input("Choose: "))
if category == "a":
choices()
choice = str(input("Choose: "))
#subtraction
if choice == "a":
a = int(input("1: "))
b = int(input("2: "))
c = a - b
print(c)
#division
elif choice == "b":
a = int(input("1: "))
b = int(input("2: "))
c = a / b
print(c)
#multiplication
elif choice == "c":
a = int(input("1: "))
b = int(input("2: "))
c = a * b
print(c)
#odd or even number
elif choice == "d":
a = int(input("Number: "))
if a % 2 == 0:
print("The number",a,"is an even number")
else:
print("The number",a,"is an odd number")
#Perimeter
elif choice == "e":
#Choose perimeter shape
print("Choices (for shapes):")
print("'a' for squares")
print("'b' for triangles")
d = str(input("Shape: "))
#square calculation
if d == "a":
a = int(input("Height: "))
b = int(input("Width: "))
d = (a * 2) + (b * 2)
#triangle calculation
elif d == "b":
a = int(input("Length of first wall: "))
b = int(input("Length of second wall: "))
c = int(input("Length of third wall: "))
d = a + b + c
#answer
print("Perimeter:",d)
#addition
elif choice == "f":
a = int(input("1: "))
b = int(input("2: "))
c = a + b
print(c)
#averages
elif choice == "g":
#required
amt = 0
sum = 0.0
num = 1
#keep in mind
print("Enter 0 to stop cycle")
#the real math
while num != 0:
num = float(input("Enter number: "))
if num != 0:
amt = amt + 1
sum = sum + num
if num == 0:
print("Average:", sum / amt)
#misc
if category == "b":
misc_categories()
choices = str(input("Choose: "))
if choices == "a":
months = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October",
"November", "December"]
month = int(input("Number of month: "))
if 1 < month <= 12:
print("The month is",months[month-1])
else:
quit()