Question: Apply data structures to store and process information, and write Python code for each task. Question 2a staffSalaryList is a list of elements where

Apply data structures to store and process information, and write Python code 

Apply data structures to store and process information, and write Python code for each task. Question 2a staffSalaryList is a list of elements where each element is a list of two elements - staff number and salary for a staff. Staff numbers are unique in staffSalaryList but salaries are not unique. (i) Update the salary for the first element in staffSalaryList to 2500. (ii) Locate the salary of staff with staff number p123. If the staff can be located, update salary to 3600 and print Updated! If staff cannot be located, print Unable to locate. (iii) (iv) (i) (ii) Question 2b Process the same data in staffsalaryList in Q2(a) now recorded in a dictionary staffSalaryDict with staff number as key and salary as value. Initialise staffSalaryDict using the data in staffSalaryList. Determine and print the number of staff number and salary pairs there are in (iii) Compute the average salary of staff. Print the staff number whose salary is above the average salary. (iv) Print the staff number in descending order of salary and in ascending order of staff number, that is, print the staff number of the staff with the highest salary first, and if the salaries tie, print the smaller staff number first. Do not print the salary. (10 marks) staffSalaryDict. Locate the salary of staff with staff number p123. If the staff can be located, update salary to 3600 and print Updated! If staff cannot be located, print Unable to locate. Print the staff number and salary of staff in ascending order of salary and in ascending order of staff number if the salaries tie. (11 marks) Question 2c Based on the operations in Q2(a) and Q2(b), explain which operations are best suited for list and which operations are best suited for dictionary. Use the operations in Q2(a) and 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

the code consists of different steps for the operations on both list and dictionary please try to excute both the list operations and dictionary opera... 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!