You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
21 lines
506 B
21 lines
506 B
num1 = float(input("Enter first number: ")) |
|
num2 = float(input("Enter second number: ")) |
|
operator = input("Enter operator (+, -, *, /): ") |
|
|
|
if operator == '+': |
|
result = num1 + num2 |
|
elif operator == '-': |
|
result = num1 - num2 |
|
elif operator == '*': |
|
result = num1 * num2 |
|
elif operator == '/': |
|
if num2 == 0: |
|
print("Error: Division by zero") |
|
else: |
|
result = num1 / num2 |
|
else: |
|
print("Invalid operator") |
|
result = None |
|
|
|
if result is not None: |
|
print("Result:", result)
|
|
|