PYTHON CODING
# Get input for the first number
num1 = int(input("Enter the first number: "))
#Get input for the second number
num2 =int(input("Enter the second number: "))
#Get input for the operator
operator = input("Enter an operator (+, -, *, /): ")
#Perform the calculation based on the operator
ifoperator == '+':
result = num1 + num2
print(num1," + ", num2, "=" ,result)
elifoperator == '-':
result = num1 - num2
print(num1," - ",num2,"=",result)
elifoperator == '*':
result = num1 * num2
print(num1," * ",num2,"=",result)
elifoperator == '/':
if num2 != 0: # Handle division by zero
result = num1 / num2
print(num1," / ",num2," = ",result)
else:
print("Error: Division by zero is not allowed.")
else:
print("Invalid operator entered.")
OUTPUT
CASE1
Enter the first number: 4
Enter the second number: 5
Enter an operator (+, -, *, /): +
4+ 5 = 9
CASE2
Enterthe first number: 5
Enterthe second number: 8
Enteran operator (+, -, *, /): -
5-8= -3
CASE3
Enterthe first number: 8
Enterthe second number: 2
Enteran operator (+, -, *, /): *
8*2= 16
CASE4
Enterthefirst number: 12
Enterthesecond number: 3
Enteranoperator (+, -, *, /): /
12/3=4.0