This repository has been archived by the owner on Jan 14, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathPython_Text_Calculator.py
84 lines (66 loc) · 2.45 KB
/
Python_Text_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
def Calculator():
calc = input("What kind of calculation do you wish to do? (type ? for help): ")
if calc == "?":
print("Currently supported: multiplication(*), division(/), addition(+), square (sq), subtraction (-) and modulo (%)")
print("")
Calculator();
elif calc == "*":
print("")
number1 = int(input("Please select the first number: "))
number2 = int(input("Please select the second number: "))
print("Answer: ", number1 * number2)
print("")
Calculator();
elif calc == "sq":
print("")
number1 = int(input("Please select the first number: "))
print("Answer: ", number1 * number1)
print("")
Calculator();
elif calc == "/":
print("")
number1 = int(input("Please select the first number: "))
number2 = int(input("Please select the second number: "))
print("Answer: ", number1 / number2)
print("")
Calculator();
elif calc == "-":
print("")
number1 = int(input("Please select the first number: "))
number2 = int(input("Please select the second number: "))
print("Answer: ", number1 - number2)
print("")
Calculator();
elif calc == "+":
print("")
number1 = int(input("Please select the first number: "))
number2 = int(input("Please select the second number: "))
print("Answer: ", number1 + number2)
print("")
Calculator();
elif calc == "%":
print("")
try:
number1 = int(input("Please select the first number(greater): "))
number2 = int(input("Please select the second number(smaller): "))
except (TypeError, ValueError):
print("Invalid input")
print("")
Calculator();
if(abs(number1)<abs(number2)):
print("")
print("The second number entered is greater than the bigger number")
print("")
Calculator();
print("Answer: ", number1-number2*int(number1/number2))
print("")
Calculator();
elif calc == "exit":
exit();
else:
print("")
print("Sorry, I don't understand your request. Currently supported calculations: *, /, -, + and % (MODULO). Sorry for the inconvenience!")
print("")
Calculator();
print("")
Calculator();