This program is a simple calculator that performs addition, subtraction, multiplication, and division.
op = input("Enter operator (+, -, *, /): ")
num1 = float(input("Enter first number: "))
num2 = float(input("Enter second number: "))
if op == '+':
print(num1 + num2)
elif op == '-':
print(num1 - num2)
elif op == '*':
print(num1 * num2)
elif op == '/':
if num2 != 0:
print(num1 / num2)
else:
print("Error! Division by zero.")
else:
print("Invalid operator")
No comments:
Post a Comment