Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 6##Create a basic operations calculator with the following features:
- ##1. Allow for the basic operations (add, subtract, multiply, divide) between TWO numbers
- ##2. Display the answer and allow them to perform another calculation
- ##3. Program the calculators using FUNCTIONS, PARAMETERS, and RETURN VALUES
- ##
- ##I will give you a preview of my program
- #def addNumbers(x, y)
- #return x + y
- print("Hello welcome to the one and only free python calculator")
- print("This calculator is able to do addition,subtraction,multiplication and division")
- print("Pick your operation")
- print("[1] Addition")
- print("[2] Subtraction")
- print("[3] Multiplication")
- print("[4] Division")
- while True:
- operation = int(input())
- if operation == 1:
- print("Please input the values you wish to add together")
- x = int(input())
- y = int(input())
- def addNumbers(x, y):
- return x + y
- print("Your answer is " + str(addNumbers(x, y)))
- if operation == 2:
- print("Please input the values you wish to subtract")
- x = int(input())
- y = int(input())
- def subtractNumbers(x, y):
- return x - y
- print("Your answer is " + str(subtractNumbers(x, y)))
- if operation == 3:
- print("Please input the values you wish to multiply")
- x = int(input())
- y = int(input())
- def multiplyNumbers(x, y):
- return x * y
- print("Your answer is " + str(multiplyNumbers(x, y)))
- if operation == 4:
- print("Please input the values you wish to divide")
- x = int(input())
- y = int(input())
- def divideNumbers(x, y):
- return(x / y)
- print("Your answer is " + str(divideNumbers(x, y)))
- redo = input("Would you like to do another calculation [Yes] [No]\n")
- if redo.lower() != "yes":
- break
- else:
- print("Choose another operation")
- continue
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement