# define the calculator function
def calculator():
# take user input for the first number
num1 = float(input("Enter the first number: "))
# take user input for the operation
op = input("Enter the operation (+, -, *, /): ")
# take user input for the second number
num2 = float(input("Enter the second number: "))
# perform the operation based on user input
if op == "+":
result = num1 + num2
elif op == "-":
result = num1 - num2
elif op == "*":
result = num1 * num2
elif op == "/":
result = num1 / num2
else:
print("Invalid operation.")
return
# print the result
print("The result is:", result)
# call the calculator function
calculator()
The code prompts the user to enter the first number, the operation, and the second number, then performs the calculation based on the user's input and prints the result.The code prompts the user to enter the first number, the operation, and the second number, then performs the calculation based on the user's input and prints the result.