-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPythonCalculator_21July_2022.py
More file actions
38 lines (29 loc) · 1.4 KB
/
PythonCalculator_21July_2022.py
File metadata and controls
38 lines (29 loc) · 1.4 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
while 2 > 1:
print("Enter the corresponding number of the operation you would wish to perform : ")
userinput = int(input("1 for Addition, 2 for Subtraction, 3 for multiplication, 4 for division : "))
if userinput > 4:
print("Invalid input")
break
numinput = int(input("Enter the 1st number = "))
num2input = int(input("Enter the 2nd number = "))
if userinput == 1:
result_add = numinput + num2input
print("You have selected 1) Addition. The result of", numinput, "and", num2input, "is equal to", result_add)
if userinput == 2:
result_subtract = numinput - num2input
print("You have selected 2) Subtraction. The result of", numinput, "and", num2input, "is equal to",
result_subtract)
if userinput == 3:
result_multiply = numinput * num2input
print("You have selected 3) Multiply. The result of", numinput, "and", num2input, "is equal to",
result_multiply)
if userinput == 4:
result_divide = numinput / num2input
print("You have selected 4) Divide. The result of", numinput, "and", num2input, "is equal to", result_divide)
print("End of program.")
run_consent = input("Would you like to run the program again? Y for Yes, N for No = ")
if run_consent == 'Y':
pass
else:
print("Program has stopped")
exit()