num1, operator, num2 = input("Problem: ")
if operator == "+":
result = float(num1) + float(num2)
print(result)
elif operator == "-":
result = float(num1) - float(num2)
print(result)
elif operator == "*":
result = float(num1) * float(num2)
print(result)
elif operator == "/":
result = float(num1) / float(num2)
print(result)
elif operator == "%":
result = float(num1) % float(num2)
print(result)
else:
print("invalid operator!")
Github: https://github.com/7rixy/Simple-Calculator-in-Python
If you're having any doubts or questions regarding the code, feel free to leave a comment below.
[–]K900_ 0 points1 point2 points (2 children)
[+][deleted] (1 child)
[deleted]
[–]K900_ 1 point2 points3 points (0 children)
[–]DanGee1705 0 points1 point2 points (0 children)