- 1
Please can anyone assist to debug this program for me?
Its just a simple calculator using if statement in Python https://code.sololearn.com/csq1bt959x9H/?ref=app
4 Antworten
+ 3
op should be a string variable not float.
op = input("Enter operand")
0
It seems to work, what are you having issues with? Of course the scanf can be exploited but your code works.
0
num1 = float(input("First Number:"))
op = float(input("Enter operand"))
num2 = float(input("Enter Second Number"))
if op == "+":
print(num1 + num2 )
elif op == "*":
print(num1 * num2 )
elif op == "-":
print(num1 - num2 )
elif op == "/":
print(num1 / num2 )
else:
print("invalid operator")
0
I cant able to run this program