Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def do_calculation():
- command = input("Enter a command to add or subtract or average: ")
- print("Let's", command, "some numbers")
- if command == "add":
- number1 = int(input("Number 1: "))
- number2 = int(input("Number 2: "))
- result = number1 + number2
- print(number1, "+",number2, "=", result)
- elif command == "subtract":
- number1 = int(input("Number 1: "))
- number2 = int(input("Number 2: "))
- result = number1 - number2
- print(number1, "-", number2, "=" , result)
- elif command == "average":
- how_many = input("How many numbers do you want to average? ")
- how_many = int(how_many)
- total = 0
- for number_count in range(how_many):
- number = input("Enter number " + str(number_count) + " = ")
- total = total + int(number)
- result = total / how_many
- print("average is = " + str(result))
- else:
- print("This command is not recognized. Bye.")
- do_calculation()
Advertisement
Add Comment
Please, Sign In to add comment