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

Popular posts from this blog

Maths Unit 1 ( Theory )

Intelligence System notes part 2

code for find the determinant of 3x3 matrix