Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Input players scores and calculate seasons performance
- # List Variable for players performance
- performance = []
- # Function to calculate average
- def players_average(players_performance):
- difference = 0 # set variable to 0 at start
- played = 0
- for item in performance: # total the values in list
- difference += item
- played += 1 # counting how many items there are
- return difference / played # return total divided by count
- # Variable to keep loop running
- more = 'Y'
- # Get players scores from user
- while more == 'Y':
- points_for = int(input("What did player score "))
- points_against = int(input("What did the opponent score "))
- performance.append(points_for - points_against)
- more = (input("Input another score Y or N ")).upper()
- print()
- # Produce output using my average function and built in max and min
- print("Players average is {}".format(players_average(performance)))
- print("Players best win was by {} points".format(max(performance)))
- print("Players worst defeat was {} points".format(min(performance)))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement