-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
executable file
·76 lines (47 loc) · 1.33 KB
/
main.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
def end():
repeat = input('Would you like to do another calculation? (Y or N, caps sensitive)')
if repeat == 'Y':
calculate()
if repeat == "N":
exit()
def add():
num1 = float(input('what is your first number? '))
num2 = float(input('what is your second number? '))
answer = num1 + num2
print(answer)
end()
def sub():
num1 = float(input('what is your first number? '))
num2 = float(input('what is your second number? '))
answer = num1 - num2
print(answer)
end()
def div():
num1 = float(input('what is your first number? '))
num2 = float(input('what is your second number? '))
try:
answer = num1 / num2
except ZeroDivisionError:
answer = 0
print(answer)
end()
print(answer)
end()
def mul():
num1 = float(input('what is your first number? '))
num2 = float(input('what is your second number? '))
answer = num1 * num2
print(answer)
end()
repeat = "Y"
def calculate():
sign = input('Would you like to add, subtract, divide, or multiply? ')
if sign == "add":
add()
elif sign == "subtract":
sub()
elif sign == "divide":
div()
elif sign == "multiply":
mul()
calculate()