watermark logo

Tiếp theo

Tự chạy

Python calculator program 🧮

0 Lượt xem • 10/30/24
Đăng lại
Nhúng
121gamers
121gamers
14 Người đăng ký
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")

Cho xem nhiều hơn
0 Bình luận sort Sắp xếp theo
Bình luận trên Facebook

Tiếp theo

Tự chạy