Advertisement
Guest User

Untitled

a guest
Feb 20th, 2020
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.97 KB | None | 0 0
  1. 6##Create a basic operations calculator with the following features:
  2. ##1. Allow for the basic operations (add, subtract, multiply, divide) between TWO numbers
  3. ##2. Display the answer and allow them to perform another calculation
  4. ##3. Program the calculators using FUNCTIONS, PARAMETERS, and RETURN VALUES
  5. ##
  6. ##I will give you a preview of my program
  7.  
  8. #def addNumbers(x, y)
  9. #return x + y
  10.  
  11.  
  12.  
  13. print("Hello welcome to the one and only free python calculator")
  14. print("This calculator is able to do addition,subtraction,multiplication and division")
  15. print("Pick your operation")
  16. print("[1] Addition")
  17. print("[2] Subtraction")
  18. print("[3] Multiplication")
  19. print("[4] Division")
  20. while True:
  21.  
  22. operation = int(input())
  23. if operation == 1:
  24. print("Please input the values you wish to add together")
  25. x = int(input())
  26. y = int(input())
  27. def addNumbers(x, y):
  28. return x + y
  29. print("Your answer is " + str(addNumbers(x, y)))
  30.  
  31. if operation == 2:
  32. print("Please input the values you wish to subtract")
  33. x = int(input())
  34. y = int(input())
  35. def subtractNumbers(x, y):
  36. return x - y
  37. print("Your answer is " + str(subtractNumbers(x, y)))
  38.  
  39.  
  40. if operation == 3:
  41. print("Please input the values you wish to multiply")
  42. x = int(input())
  43. y = int(input())
  44. def multiplyNumbers(x, y):
  45. return x * y
  46. print("Your answer is " + str(multiplyNumbers(x, y)))
  47.  
  48. if operation == 4:
  49. print("Please input the values you wish to divide")
  50. x = int(input())
  51. y = int(input())
  52. def divideNumbers(x, y):
  53. return(x / y)
  54. print("Your answer is " + str(divideNumbers(x, y)))
  55.  
  56. redo = input("Would you like to do another calculation [Yes] [No]\n")
  57. if redo.lower() != "yes":
  58. break
  59. else:
  60. print("Choose another operation")
  61. continue
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement