In: Computer Science
User Python to solve; show all code:
Write a program that will prompt the user for the player data described above. The user does not know how many players are on the team so allow the user to enter the word end when he/she has finished entering data.
Validate that the player is not entered more than once.
After entering the data, compute the following:
d = {}
#dictionary to store list of
player names
count = 0
#storing total points
max_count = 0
#storing maximum points by a player
best_player = "" #storing the
player's name who has best points
while True:
print("Enter player's last name, else enter end to
quit")
name = input()
if name == "end": #checking if user wants
to quit
break
if name in d.keys(): #checking for
duplicate names
print("Data already entered")
continue
print("Enter average number of points scored")
points = float(input())
print("Enter number of games projected to play")
games = int(input())
count += points * games
if max_count < points * games: #if a
new maximum value is seen
max_count = points * games
best_player = name
d[name] = [points, games] #storing the player's details in the dictionary
print()
print("Projected number of points is " + str(count))
print()
print("Best player is " + best_player + " with " + str(max_count) +
" points")