PY
py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#Provide inputs in separate lines
def calculator():
# Get inputs from the user
# Enter 1st no
num1 = int(input())
#Enter the operation (+, -, *, /, ^):
operation = input()
#Enter 2nd no
num2 = int(input("Enter the second number: "))
# Perform the calculation based on the operation
if operation == '+':
result = num1 + num2
elif operation == '-':
result = num1 - num2
elif operation == '*':
result = num1 * num2
elif operation == '/':
if num2 != 0:
result = num1 / num2
else:
return "Error: Division by zero"
elif operation == '^':
if num1 == 0 and num2 < 0:
return "Error: undefined"
Enter to Rename, Shift+Enter to Preview
OUTPUT
Run