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 doneComments
Related Programs
- Python if example
- Greatest of two numbers in Python
- Smallest of two numbers in python
- ODD or Even in Python
- 3 digit number or not in python
- Greatest of three numbers in Python
- Smallest of three numbers in Python
- Divisible by 3 or not in python
- Leap year in python
- Last digit divisible by 3 or not in python
- grade calculation in python
- else if in python
- check whether bit is set in python
- odd or even using bitwise operator in python
coming Soon
coming Soon