Test Index

CBSE Class 12 Computer Science 2024 Paper Set 4 Get it on Google PlayDownload on the App Store

© examsnet.com
Question : 34 of 35
Marks: +1, -0
(A) (i) Differentiate between 'w' and 'a' file modes in Python.
(ii) Consider a binary file, items.dat, containing records stored in the given format :
{item_id: [item_name,amount]}
Write a function, Copy_new(), that copies all records whose amount is greater than 1000 from items.dat to new_items.dat.
OR
(B) (i) What is the advantage of using with clause while opening a data file in Python ? Also give syntax of with clause.
(ii) A binary file, EMP.DAT has the following structure :
[Emp_Id, Name, Salary]
where
Emp_Id : Employee id
Name : Employee Name
Salary : Employee Salary
Write a user defined function, disp_Detail(), that would read the contents of the file EMP.DAT and display the details of those employees whose salary is below 25000.
Advertisements
Go to Question: