The following example code demonstrates how to Create a Calculator to Perform Arithmetic Operations in Python.

Basically, here we perform the four arithmetic operations of add, subtract, multiplication, and division on two numbers. Furthermore, we take the input numbers from the user. So, the user needs to enter input values separated by a comma. Since the python function named operations returns the four resulting values. So, the variable result retrieves these values. Finally, we display the resulting values using the print statement.

``````# programmingempire.com

def operation(a,b):
sub = a-b
mul=a*b
if a>b:
div = a/b
else:
div = b/a
n1,n2=eval(input("enter 2 numbers separated by comma"))
result = operation(n1,n2)
print(result)``````

Output

Python Practice Exercise

Examples of OpenCV Library in Python

Examples of Tuples in Python

Python List Practice Exercise

A Brief Introduction of Pandas Library in Python

A Brief Tutorial on NumPy in Python

princites.com

IITM Software Development Cell