Ask Question
19 April, 11:38

Prompt the user to input five pairs of numbers: A player's jersey number (0 - 99) and the player's rating (1 - 9). Store the jersey numbers and the ratings in a dictionary. Output the dictionary's elements with 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. (3 pts)

+4
Answers (1)
  1. 19 April, 14:21
    0
    jersey_dict = {} for i in range (5) : j_num = int (input ("Input Jersey's number (0-99) : ")) rating = int (input ("Input rating (1 - 9) : ")) jersey_dict[j_num] = rating sorted_key = [] for i in jersey_dict. keys () : sorted_key. append (i) sorted_key. sort () for i in sorted_key: print (str (i) + ":" + str (jersey_dict[i]))

    Explanation:

    Firstly, define an empty dictionary (Line 1).

    Next, use a for loop to prompt user to input five Jersey's number and rating and keep the input to the dictionary (Line 3-6). Next, create a list to hold the dictionary keys (Line 8-10). Use build in method, sort to arrange the keys in the list in ascending order (Line 12). At last, print the dictionary element by looping over the value in the sorted_key list (Line 14-15).
Know the Answer?
Not Sure About the Answer?
Find an answer to your question ✅ “Prompt the user to input five pairs of numbers: A player's jersey number (0 - 99) and the player's rating (1 - 9). Store the jersey numbers ...” in 📘 Computers and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers