Question: Write a program that writes the above records to a file in order to read these records later by the records' IDs (Random Access).
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']
Step by Step Solution
3.48 Rating (158 Votes )
There are 3 Steps involved in it
import pickle def writerecordsfilename records with openfilename wb as f Wr... View full answer
Get step-by-step solutions from verified subject matter experts
