IN PYTHON PLEASE Soccer team roster (Dictionaries) (1) Prompt the user to input
ID: 3731131 • Letter: I
Question
IN PYTHON PLEASE Soccer team roster (Dictionaries) (1) Prompt the user to input five pairs of numbers. A players jersey number(0-99) and the players rating(1-9). Store the jersy numbers and the ratings in a dictionary. Output the dictionary ‘s elements woth the jersey numbers in ascending order (i.e. output the roster from smallest to largest jersey number) Hint, dictionary keys can be stored in a sorted list. (2) Implement a menu of options for a user to modify the roster. Each option is represented by a single character. The program initially outputs the menu, and outputs the menu after a user chooses an option. The program ends when the user chooses the option to quit. For this step, the other options do nothing. (3) Implemt the “Output roster” menu option. (4). Implement the “Add player” menu option. Prompt the user for a new player’s jersey number and rating. Append the valuse to the 2 vectors. (5) Implement the “Delete player” menu option. Prompt the user for a player’s jersey number. Remove the player from the roster (delete the jersey number and rating.) (6) Implement the “Updat player rating”menu option. Prompt the user for a player’s jersey number. Prompt again for a new rating for the player and then change that player’s rating. (7) Implement the “Output players above a rating “ menu option. Prompt the user for a rating. Print the jersey number and rating for all players with ratings above the entered value. IN PYTHON PLEASE Soccer team roster (Dictionaries) (1) Prompt the user to input five pairs of numbers. A players jersey number(0-99) and the players rating(1-9). Store the jersy numbers and the ratings in a dictionary. Output the dictionary ‘s elements woth the jersey numbers in ascending order (i.e. output the roster from smallest to largest jersey number) Hint, dictionary keys can be stored in a sorted list. (2) Implement a menu of options for a user to modify the roster. Each option is represented by a single character. The program initially outputs the menu, and outputs the menu after a user chooses an option. The program ends when the user chooses the option to quit. For this step, the other options do nothing. (3) Implemt the “Output roster” menu option. (4). Implement the “Add player” menu option. Prompt the user for a new player’s jersey number and rating. Append the valuse to the 2 vectors. (5) Implement the “Delete player” menu option. Prompt the user for a player’s jersey number. Remove the player from the roster (delete the jersey number and rating.) (6) Implement the “Updat player rating”menu option. Prompt the user for a player’s jersey number. Prompt again for a new rating for the player and then change that player’s rating. (7) Implement the “Output players above a rating “ menu option. Prompt the user for a rating. Print the jersey number and rating for all players with ratings above the entered value. Soccer team roster (Dictionaries) (1) Prompt the user to input five pairs of numbers. A players jersey number(0-99) and the players rating(1-9). Store the jersy numbers and the ratings in a dictionary. Output the dictionary ‘s elements woth the jersey numbers in ascending order (i.e. output the roster from smallest to largest jersey number) Hint, dictionary keys can be stored in a sorted list. (2) Implement a menu of options for a user to modify the roster. Each option is represented by a single character. The program initially outputs the menu, and outputs the menu after a user chooses an option. The program ends when the user chooses the option to quit. For this step, the other options do nothing. (3) Implemt the “Output roster” menu option. (4). Implement the “Add player” menu option. Prompt the user for a new player’s jersey number and rating. Append the valuse to the 2 vectors. (5) Implement the “Delete player” menu option. Prompt the user for a player’s jersey number. Remove the player from the roster (delete the jersey number and rating.) (6) Implement the “Updat player rating”menu option. Prompt the user for a player’s jersey number. Prompt again for a new rating for the player and then change that player’s rating. (7) Implement the “Output players above a rating “ menu option. Prompt the user for a rating. Print the jersey number and rating for all players with ratings above the entered value.Explanation / Answer
def output_menu(): print("1. Output Roster") print("2. Add player") print("3. Delete player") print("4. Update player's rating") print("5. Output player's above a rating") print("6. Quit") def output_roster(roster): keys = roster.keys() for i in keys: print("Jersey Number: " + str(i) + " ratings: "+str(roster[i])) def add_player(roster): a, b = input("Enter Jersey No. and ratings: ").split() roster[a] = int(b[0]) def delete_player(roster): a = input("Enter player's jersey number: ").split() if a[0] in roster: del roster[a[0]] else: print("This player is not present") def update_player_rating(roster): a = input("Enter player's jersey number: ").split() b = input("Enter player's ratings: ").split() roster[a[0]] = int(b[0]) def output_roster_above_rating(roster): a = input("Input threshold rating: ") a = int(a[0]) for i in roster.keys(): if int(roster[i]) > a: print("Jersey Number: " + str(i) + " ratings: " + str(roster[i])) def main(): soccer_team_roster = {} for i in range(0, 5): a, b = input("Enter Jersey No. and ratings: ").split() soccer_team_roster[a] = int(b[0]) jersey_num = sorted(soccer_team_roster.keys()) # output dictionary elements in ascending order for i in jersey_num: print("Jersey No: " + str(i) + " ratings: " + str(soccer_team_roster[i])) while True: output_menu() option = input() option = int(option) if option == 1: output_roster(soccer_team_roster) elif option == 2: add_player(soccer_team_roster) elif option == 3: delete_player(soccer_team_roster) elif option == 4: update_player_rating(soccer_team_roster) elif option == 5: output_roster_above_rating(soccer_team_roster) elif option == 6: exit() else: print("Not a right option") if __name__ == '__main__': main()