← 피드로
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”)
Top comments (0)
Subscribe
Code of Conduct • Report abuse
For further actions, you may consider blocking this person and/or reporting abuse
추출 본문 · 출처: dev.to · https://dev.to/mashadpixel/made-a-calculator-512
답글 남기기