Write a program that writes the above records to a file in order to read these...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Write a program that writes the above records to a file in order to read these records later by the records' IDs (Random Access). Note that the records do not have a fixed number of attributes. For example, s1 has 3 attributes while s3 has 5 attributes. Hint: write the number of attributes before writing the actual record to the file, so when reading you know how many attributes you are expecting s1 = ['100', 'Ali', 'IS'] s2 = ['200', 'Ahmed', '2.5', 'CS'] s3 = ['300', 'Khalid', '3.9', 'IS', 'undergrad'] s4= ['400', 'Nasser', 'SE', 'grad'] s5 = ['500', 'Jamal', '4.5', 'CS'] Write a program that writes the above records to a file in order to read these records later by the records' IDs (Random Access). Note that the records do not have a fixed number of attributes. For example, s1 has 3 attributes while s3 has 5 attributes. Hint: write the number of attributes before writing the actual record to the file, so when reading you know how many attributes you are expecting s1 = ['100', 'Ali', 'IS'] s2 = ['200', 'Ahmed', '2.5', 'CS'] s3 = ['300', 'Khalid', '3.9', 'IS', 'undergrad'] s4= ['400', 'Nasser', 'SE', 'grad'] s5 = ['500', 'Jamal', '4.5', 'CS']
Expert Answer:
Answer rating: 100% (QA)
import pickle def writerecordsfilename records with openfilename wb as f Wr... View the full answer
Related Book For
Income Tax Fundamentals 2013
ISBN: 9781285586618
31st Edition
Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill
Posted Date:
Students also viewed these computer network questions
-
Find the eigenvalues and the corresponding eigenvectors for the following 3x3 matrix. -1 0 A -1 2 0-1
-
In this project, we will write a program that controls a quiz show, much like the many popular TV shows. The program will read in a group of questions and their multiple choice answers, storing them...
-
Planning is one of the most important management functions in any business. A front office managers first step in planning should involve determine the departments goals. Planning also includes...
-
The stockholders' equity accounts of Marya Corporation on January 1, 2014, were as follows. Preferred Stock (9%, $100 par, cumulative, 5,000 shares authorized) ...$300,000 Common Stock ($3 stated...
-
Why do writers of most e-mails and memos frontload-that is, reveal the main idea immediately in the opening?
-
Modify Diagram 8, INSTALL SOFTWARE. Add the following processes, describing each in the repository. Zoom to 100 percent and scroll around the screen, checking your diagram for a professional...
-
Why are communications between a lawyer and the client subject to the lawyer-client privilege?
-
If Wild Widgets, Inc., were an all-equity company, it would have a beta of .85. The company has a target debtequity ratio of .40. The expected return on the market portfolio is 11 percent, and...
-
Assume quantities must be integers. Assume costs and prices in Indian Rupees. A monopolist constrained to charging the same price for each unit incurs a per-unit cost of 6 and faces the following...
-
The government has just increased taxes. a. Demonstrate the effect on the price level and output in the standard model. b. How would your answer to a differ if there were partial crowding out? c. How...
-
A fabrication shop makes two types of valve actuators for explosive environments call them A and B. This actuator requires special manufacturing processes so there is one production line dedicated...
-
Calculate the MONTHLY straight line depreciation expense for the following assets: a. Vehicle purchased for $35,000. The vehicle has a salvage value of $2,500 and an estimated useful life of 4 years...
-
Charming Clothiers manufactures neckties and bow ties. The company has the following information: The company s sales price is $ 3 0 per unit. The variable costs of producing bowties is $ 1 8 per...
-
Debit Credit Account Balances Cash = $4,000 Buildings = $15,000 Accounts Payable = $3,000 Common Stock = $9,000 Retained Earnings = $5,000 Service Revenue = $13,000 Salaries Expense = $11,000 What is...
-
Case brief assignment. The case you must locate and summarize is: R. v. Mohan, [1994] 2 S.C.R. 9 Source: https://scc-csc.lexum.com/scc-csc/scc-csc/en/item/1131/index.do Breakdown of Marks and...
-
4. Given the function below, find the following. For credit you must show complete and correct to support your answers. (10 points; 2 points each) f(x, y) = xy + ex-2 a. fx (2,1) b. fy(2,1) c....
-
The population reached a total of 2495 people in the year
-
Fill in each blank so that the resulting statement is true. 83 + 103 = ______ .
-
The following additional information is available for the Dr. Ivan and Irene Incisor family from Chapters 1 and 2. On September 1, Irene opened a retail store that specializes in sports car...
-
For each of the following situations, indicate whether the taxpayer(s) is (are) required to file a tax return for 2012. Explain your answer. a. Helen is a single taxpayer with interest income in 2012...
-
Diane is a single taxpayer who qualifies for the earned income credit. Diane has two qualifying children who are 3 and 5 years old. During 2012, Diane's wages are $17,100 and she receives dividend...
-
Using the online code for the example in this chapter as a starting point and the solution from a previous exercise. 1. Implement (or modify your previous) Student: :DropCourse (). When a student...
-
Using the Adapter examples found in this chapter, create a program as follows: 1. Implement a Citizen Data Base that stores various types of Humanoid instances (Orkan, Romulan, Earthling, and perhaps...
-
Using the solution from a previous exercise, augment your code as follows: 1. Implement the Factory Method pattern to create various shapes. You will have already created an abstract base class of...
Study smarter with the SolutionInn App