Question: Process the same data in staffSalaryList, now recorded in a dictionary staffSalaryDict with staff number as key and salary as value. (i) Initialise staffSalaryDict using

Process the same data in staffSalaryList, now recorded in a dictionary staffSalaryDict with staff number as key and salary as value.
(i) Initialise staffSalaryDict using the data in staffSalaryList.
(ii) Determine and print the number of staff number and salary pairs there are in staffSalaryDict.
(iii) Locate the salary of staff with staff number p123. If the staff can be located, update the salary to 3600 and print Updated! If staff cannot be located, print Unable to locate.
(iv) Print the staff number and salary of staff in ascending order of salary and in ascending order of staff number if the salaries tie.
Based on the operations, explain which operations are best suited for the list and which operations are best suited for the dictionary. Use the operations in Q2(b) in your explanation. (4 marks)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

i Initializing staffSalaryDict using the data in staffSalaryList is best suited for a dictionary bec... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!