Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def do_calculation():
- print("lets do some " + command + " calculation.")
- #ask user how many numbers wants
- 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 = adding total to integer number which user has input
- total = total + int(number)
- #result is total divide to variable(how_many) which stores amount of numbers input by user
- result = total / how_many
- if command == "average":
- print("the average = " + str(result))
- elif command == "total":
- #prints total
- print("total = " + str(total))
- finished = False
- while finished == False:
- print("Hi, I am Marvin, your personal bot.")
- command = input("How can I help? ")
- if command == "average":
- do_calculation()
- elif command == "total":
- do_calculation()
- elif command == "bye":
- finished = True
- else:
- print("sorry I dont understand")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement