timpin

Untitled

Aug 19th, 2019
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. def total_or_average():
  2. input_set = []
  3. how_many = input("How many numbers do you want to " + command + "? ")
  4. howmany = int(how_many)
  5. total = 0
  6. for number_count in range(howmany):
  7. number = input("Enter number " + str(number_count + 1) + "> ")
  8. input_set.append(number)
  9. total = total + int(number)
  10. average = total / howmany
  11. if command == "total":
  12. result = total
  13. elif command == "average":
  14. result = average
  15.  
  16. print("the " +command+ " of" + str(input_set) + " is " + str(result))
Advertisement
Add Comment
Please, Sign In to add comment