-
Notifications
You must be signed in to change notification settings - Fork 3
/
Calculator.py
42 lines (41 loc) · 1.43 KB
/
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
# Write a program that performs the tasks of a simple calculator.
# The program should first take an integer as input and
# then based on that integer perform the task as given below.
# 1. If the input is 1, then 2 integers are taken from the user and
# their sum is printed.
# 2. If the input is 2, then 2 integers are taken from the user and
# their difference(1st number - 2nd number) is printed.
# 3. If the input is 3, then 2 integers are taken from the user and
# their product is printed.
# 4. If the input is 4, then 2 integers are taken from the user and
# the quotient obtained (on dividing 1st number by 2nd number) is printed.
# 5. If the input is 5, then 2 integers are taken from the user and
# their remainder(1st number mod 2nd number) is printed.
# 6. If the input is 6, then the program exits.
# 7. For any other input, then print "Invalid Operation".
while True:
i = int(input())
if(i == 1):
a = int(input())
b = int(input())
print(a+b)
elif(i == 2):
a = int(input())
b = int(input())
print(a-b)
elif(i == 3):
a = int(input())
b = int(input())
print(a*b)
elif(i == 4):
a = int(input())
b = int(input())
print(a//b)
elif(i == 5):
a = int(input())
b = int(input())
print(a % b)
elif(i == 6):
break
else:
print("Invalid Operation")