Calculator in python
Python Program to get a binary arithmetic expression and solve the expression.
Sample Input 1:
12 + 9
Sample Output 1:
21
Sample Input 2:
4 * 5
Sample Output 2:
20
Program or Solution
num1=int(input("Enter first Number:"))
op=input("Enter Operation:")
num2=int(input("Enter Second Number:"))
if op=='+':
result=num1+num2
elif op=='-':
result=num1-num2
elif op=='*':
result=num1*num2
elif op=='/':
result=num1/num2
elif op=='%':
result=num1%num2
else:
result="invalid operation"
print(result)
Program Explanation
Based on the second input (operator) any one arthmetic operation in chained if will be done