-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfaulty no..py
More file actions
33 lines (33 loc) · 1.4 KB
/
faulty no..py
File metadata and controls
33 lines (33 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
# Exercise 2
# This Calculator will give all results correctly except the three particular
# operations which shall show the following faulty results
# 45*3 = 555, 56+9=77, 56/6=4
while(True):
var1 = int(input("Enter the First Operand\n"))
var2 = int(input("Enter the Second Operand or exponent in case of power calculation\n"))
operator=input("Enter the Type of Operation, Available Operations: + , - , * , / , ** , %\n")
if (max(var1, var2) == 45 and min(var1, var2) == 3 and operator == "*"):
print("Result:", "555")
elif (max(var1, var2) == 56 and min(var1, var2) == 9 and operator == "+"):
print("Result:", "77")
elif (var1== 56 and var2 == 6 and operator == "/"):
print("Result:", "4")
else:
if (operator == "+"):
print("Result:", var1 + var2)
elif (operator == "-"):
print("Result:", var1 - var2)
elif (operator == "*"):
print("Result:", var1 * var2)
elif (operator == "/"):
print("Result:", var1 / var2)
elif (operator=="**"):
print("Result:", var1 ** var2)
elif(operator=="%"):
print("Result:", var1 % var2)
if((input("Do you want to continue calculating? If yes type 'Y' else type 'N' \n")).capitalize()
=='Y'):
continue
else:
print("Thank You for using the Calculator")
break