Advertisement
zhongnaomi

average

Jan 10th, 2019
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.49 KB | None | 0 0
  1. print("Hi, I am Marvin, your personal bot.")
  2. command = input("How can I help? ")
  3. if command == "average" :
  4.     how_many_str = input("How many numbers> ")
  5.     how_many_int = int(how_many_str)
  6.     total = 0
  7.     for number_count in range(how_many_int):
  8.         number_str = input("Enter number " + str(number_count) + ">")
  9.         total = total + int( number_str)
  10.     result = total / how_many_int
  11.     print ("the average = " + str (result))
  12. else:
  13.     print ("Sorry, I don't understand")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement