Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- finished = False
- def do_calculation():
- print("lets " + command + " some numbers")
- input1 = input("Number 1>")
- input2 = input("Number 2>")
- number1 = int(input1)
- number2 = int(input2)
- if command == "add":
- result = number1 + number2
- elif command == "subtract":
- result = number1 - number2
- output = str(result)
- if command == "add":
- print(input1 + " + " + input2 + " = " + output)
- elif command == "subtract":
- print(input1 + " - " + input2 + " = " + output)
- def do_averege():
- how_many = input("How many numbers> ")
- 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("the average = " + str(result))
- def do_total():
- how_many = input("How many numbers> ")
- 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
- print("the average = " + str(result))
- print("Hi, I am Marvin, your personal bot.")
- while finished == False:
- command = input("How can I help? ")
- if command == "add":
- do_calculation()
- elif command == "subtract":
- do_calculation()
- elif command == "multiply":
- do_calculation()
- elif command == "divide":
- do_calculation()
- elif command == "average":
- do_average()
- elif command == "total":
- do_total()
- elif command == "bye":
- finished = True
- else:
- print("sorry I dont understand")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement