Advertisement
farrismp

Mean, Max, Min

May 1st, 2019
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.07 KB | None | 0 0
  1. # Input players scores and calculate seasons performance
  2.  
  3. # List Variable for players performance
  4. performance = []
  5. # Function to calculate average
  6. def players_average(players_performance):
  7. difference = 0 # set variable to 0 at start
  8. played = 0
  9. for item in performance: # total the values in list
  10. difference += item
  11. played += 1 # counting how many items there are
  12. return difference / played # return total divided by count
  13.  
  14. # Variable to keep loop running
  15. more = 'Y'
  16. # Get players scores from user
  17. while more == 'Y':
  18. points_for = int(input("What did player score "))
  19. points_against = int(input("What did the opponent score "))
  20. performance.append(points_for - points_against)
  21. more = (input("Input another score Y or N ")).upper()
  22. print()
  23.  
  24. # Produce output using my average function and built in max and min
  25. print("Players average is {}".format(players_average(performance)))
  26. print("Players best win was by {} points".format(max(performance)))
  27. print("Players worst defeat was {} points".format(min(performance)))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement