Advertisement
Guest User

Why is this wrong?

a guest
Dec 20th, 2015
370
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 KB | None | 0 0
  1. def add(x, y):
  2. """This function adds two numbers"""
  3.  
  4. return x + y
  5.  
  6.  
  7. def subtract(x, y):
  8. """This function subtracts two numbers"""
  9.  
  10. return x - y
  11.  
  12.  
  13. def divide(x, y):
  14. """This function divides two numbers"""
  15.  
  16. return x / y
  17.  
  18.  
  19. def multiply(x, y):
  20. """This function multiplies two numbers"""
  21.  
  22. return x * y
  23.  
  24.  
  25. print("Select Operation:")
  26. print("1.Addition")
  27. print("2.Subtraction")
  28. print("3.Multiplication")
  29. print("4.Division")
  30.  
  31. choice = input("Enter operators 1,2,3 or 4")
  32.  
  33. num1 = float(input("Enter your first number:"))
  34. num2 = float(input("Enter your second number:"))
  35.  
  36. if choice == '1':
  37. print(num1, "+", num2, "=", add(num1, num2))
  38.  
  39. elif choice == '2':
  40. print(num1, "-", num2, "=", subtract(num1, num2))
  41.  
  42. elif choice == '3':
  43. print(num1, "x", num2, "=", multiply(num1, num2))
  44.  
  45. elif choice == '4':
  46. print(num1, "÷", num2, "=", divide(num1, num2))
  47. else:
  48. print("Invalid input")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement