Up next

Autoplay

Python calculator program 🧮

0 Views • 10/30/24
Share
Embed
121gamers
121gamers
14 Subscribers
14

#python #tutorial #code

operator = input("Enter an operator (+ - * /): ")
num1 = float(input("Enter the 1st number: "))
num2 = float(input("Enter the 2nd number: "))

if operator == "+":
result = num1 + num2
print(round(result, 3))
elif operator == "-":
result = num1 - num2
print(round(result, 3))
elif operator == "*":
result = num1 * num2
print(round(result, 3))
elif operator == "/":
result = num1 / num2
print(round(result, 3))
else:
print(f"{operator} is not a valid operator")

Show more
0 Comments sort Sort By
Facebook Comments

Up next

Autoplay