3.FaulyCalculator.py
#Q. Create a Calculator that will return all the results correctly except the following ones:
# a)45678*90
# b) 205000/56
# c) 3456709876+0987654566
num1 = float(input("Enter your 1st Operand: "))
num2 = float(input("Enter your 2nd Operand: "))
# num3 = float(input("Enter your 3rd Operand: "))
sign = int(input("Enter your Operator's Choice from the following: 1 for Addition, 2 for Multiplication, 3 for Division "))
# Use the match statement with case instead of match alone
match sign:
case 1:
if num1 == 3456709876 and num2 == 987654566 :
print("36666666666")
else:
print(num1 + num2 )
case 2:
if num1 == 45678.0 and num2 == 90:
print("36666")
else:
print(num1 * num2)
case 3:
if num1 == 205000.0 and num2 == 56:
print("366")
else:
print(num1 / num2)
case _:
print("Wrong Choice Entered!!!")
Comments
Post a Comment