Fetching latest headlines…
made a calculator
NORTH AMERICA
🇺🇸 United StatesJune 29, 2026

made a calculator

0 views0 likes0 comments
Originally published byDev.to

num1 = float(input("enter a number :"))
symb = input("enter (+,-,*,/) :")
num2 = float(input("enter a number :"))

if symb == "+":
print("Answer =",num1+num2)
elif symb == "-":
print("Answer =",num1-num2)
elif symb == "*":
print("Answer =",num1*num2)
elif symb == "/":
if num2 != 0: #not to get an infinite loop as anything divided by zero is not defined
print("Answer =",num1/num2)
else:
print("Not defined as the num1 is divided by zero")
else:
print("invalid symb")

print()
print("Calculate anything else, I'm thee for you")

Comments (0)

Sign in to join the discussion

Be the first to comment!