Apply data structures to store and process information, and write Python code for each task. Question...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
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) 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)
Expert Answer:
Answer rating: 100% (QA)
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 the full answer
Related Book For
Systems analysis and design
ISBN: 978-0136089162
8th Edition
Authors: kenneth e. kendall, julie e. kendall
Posted Date:
Students also viewed these programming questions
-
The following table gives output for different numbers of workers for Shiny Sleeves, a producer of shirt varnish. Shiny Sleeve's wages are $20 per hour. For each level of workers, calculate Shiny...
-
Case Study: Quick Fix Dental Practice Technology requirements Application must be built using Visual Studio 2019 or Visual Studio 2017, professional or enterprise. The community edition is not...
-
1. Calculate the holding period return for the following two investments: Purchase Price (begining of the Stocks 5,000 Bonds 2,00 Annual Dividend 250 Annual Interest Income 200 Sale Price (end of the...
-
3. In this problem the bond sells for a premium, which indicates that interest rates have declined. The current yield is $70/$1,222 = 5.73%. To confirm that interest rates have declined, determine...
-
A uniform rod of length L and mass m is supported as shown. If the cable attached at B suddenly breaks, determine (a) The distance b for which the acceleration of end A is maximum, (b) The...
-
For each of the following systems, give two examples of how a mechanical engineer would be involved in its design. (a) Passenger automobile engine (b) Escalator (c) Computer hard disk drive (d)...
-
Use equation (17.2) to establish the following distributional relationships that are helpful for calculating quantiles. a. Assume that \(y_{0}=\alpha_{1} F / \alpha_{2}\), where \(F\) has an...
-
The following is an excerpt from a conversation between the chief executive officer, Rob Rameriz, and the chief financial officer, Maurice Chandler, of Nile Group, Inc.: Rameriz (CEO): Maurice, as...
-
Make scientific discussion and conclusion for a poster about bladeless wind turbines using the following information. Bladeless wind turbines have several promising applications due to their unique...
-
An alphabetical list of the adjusted trial balance accounts for North Country Rentals after its first year of operations ending March 31, 2020, is shown below: Required 1. Calculate the capital...
-
Explain how they differ in their view of the causes and solutions to market gluts: Ricardo and Karl Marx. Is economics is a zero-sum game? In all cases? In trade? In wealth creation? Be specific in...
-
Explain and define the concepts brain neuroplasticity, neurogenesis, and brain lateralization.
-
The price quoted for the transfers from the customer's home in Hazelwood Park to Adelaide Airport doesn't include GST. The price is $125.00. Calculate the GST to determine the selling price. Show...
-
What is the maximum penalty for using money for other purposes or incorrectly accounting for client monies under Section 211, Offences of the PSA Act 2002: What is the maximum penalty for using money...
-
For the fiscal year 2019-2020, Amazon was following straight line method of depreciation, but from the year 2021-2022, the company plans to use double declining method of depreciation. The Amazon's...
-
Becky owns a bridal accessories store. Her total revenue last year was $173,000. Her rent was $10,000, she paid workers $75,000, and her overhead expenses were $20,000. Becky knows that she could...
-
Draw the free-body diagram for the beam. A isa rocker and B is a pin. Draw the vectors starting at the black dots. The location andorientation of the vectors will be graded. The length of thevectors...
-
Smiths Family Fashions implemented a balanced scorecard performance measurement system several years ago. Smiths is a locally owned clothing retailer with fashions for men, women, teens, and...
-
List four guidelines to facilitate the design of good display output.
-
Why are structural records used?
-
Draw a local area network or some other configuration of distributed processing using the client/server approach to solve some of the data sharing problems that Bakerloo Brothers is having. It wants...
-
What is the value of equity at time zero? A. 44,055. B. 77,973. C. 122,027. Mun Hoe Yip is valuing Pure Corporation. Pure is a simple corporation that is going out of business in five years,...
-
Economic income during Year 1 is closest to: A. 23,186. B. 29,287. C. 46,101. Mun Hoe Yip is valuing Pure Corporation. Pure is a simple corporation that is going out of business in five years,...
-
What is residual income during Year 1? A. 2,916. B. 2,542. C. 8,653. Mun Hoe Yip is valuing Pure Corporation. Pure is a simple corporation that is going out of business in five years, distributing...
Study smarter with the SolutionInn App