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):
add = a+b
sub = a-b
mul=a*b
if a>b:
div = a/b
else:
div = b/a
return add,sub,mul,div
n1,n2=eval(input("enter 2 numbers separated by comma"))
result = operation(n1,n2)
print(result)
Output
Further Reading
Examples of OpenCV Library in Python
A Brief Introduction of Pandas Library in Python