-
Notifications
You must be signed in to change notification settings - Fork 30
/
pycalci.py
51 lines (39 loc) · 1.14 KB
/
pycalci.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
def add(num1, num2):
return num1 + num2
def subtract(num1, num2):
return num1 - num2
def multiply(num1, num2):
return num1 * num2
def divide(num1, num2):
return num1 / num2
loop=1
while loop==1:
print("Please select operation -\n" \
"1. Add\n"\
"2. Subtract\n" \
"3. Multiply\n" \
"4. Divide\n" \
"5. Exit")
try:
select = int(input("--> "))
if(select==5):
loop=0
elif(select>5) :
print("HEYYY,read the damn instructions!\n Do you want to try again?")
else:
number1 = int(input("Enter first number: "))
number2 = int(input("Enter second number:"))
#after selection
if (select == 1):
print(number1, "+", number2, "=",add(number1, number2))
elif (select == 2):
print(number1, "-", number2, "=",subtract(number1, number2))
elif (select == 3):
print(number1, "*", number2, "=",multiply(number1, number2))
elif (select == 4):
if (number2 == 0):
print("[Sorry, the scientist are still figuring out that one]\n")
else:
print(number1, "/", number2, "=",divide(number1, number2))
except:
print("[error, this is IMPOSSIBLE!\n Do you want to try again?]\n")