code for a simple calculator
def add(a,b):
result=(a+b)
print(result)
def sub(a,b):
result=(a-b)
print(result)
def mul(a,b):
result=(a*b)
print(result)
def div(a,b):
result=(a/b)
print(result)
a=int(input("Enter the first number: "))
b=int(input("Enter the second number: "))
op=input("Enter the operator: ")
if op=="+":
print(add(a,b))
elif op=="-":
print(sub(a,b))
elif op=="*":
print(mul(a,b))
elif op=="/":
print(div(a,b))
else:
print("Enter the correct operator.\n" )
Comments
Post a Comment