From 968e5e37f295c170f83db3a8a23551544e7f6fba Mon Sep 17 00:00:00 2001 From: julia-p-laiju Date: Thu, 22 Feb 2024 15:20:48 +0530 Subject: [PATCH] Fixed bug 1 and 2 --- calculator.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/calculator.py b/calculator.py index 2550c49..4ef1758 100644 --- a/calculator.py +++ b/calculator.py @@ -1,13 +1,11 @@ -# # calculator.py -# # Asks user for 2 operands and 1 operator # Returns output of this operation -a=input("Enter number 1 : ") +a=float(input("Enter number 1 : ")) o=input("Enter operator : ") -b=input("Enter number 2 : ") +b=float(input("Enter number 2 : ")) if o[0] in [ '+','-','*','/' ]: if o[0] == '+': @@ -17,7 +15,11 @@ elif o[0] == '*': out = a * b elif o[0] == '/': - out = a//b + if b == 0: + print("Divide by zero error") + exit() + else: + out = a//b print("Output : ",out) else: print("Error : Invalid Operator")