Answers for "Make a simple calculator using python functions"

0

Make a simple calculator using python functions

#Define the function
def Calc(n1, n2, op):
  ans = 0

  if op == '+':
    ans = n1 + n2
  elif op == '-':
    ans = n1 - n2
  elif op == '*':
    ans = n1 * n2
  elif op == '/':
    ans = n1 / n2
  else:
    ans = "Invalide Operator"

  return ans

#input the two numbers
num1, num2 = int(input("Enter the first number:")), int(input("Enter the second number:"))

#input the operator
op = input("Enter the operator you want:")

ans = Calc(num1, num2, op)

print("The answer:", ans)
Posted by: Guest on October-30-2021

Code answers related to "Make a simple calculator using python functions"

Python Answers by Framework

Browse Popular Code Answers by Language