Friday, 24 July 2026
Lecture 34 of 73 · Unit 1
Unit 1 ⏳ Pending
Unlocks at 05:00 PM, 24 Jul 2026

Binary file operations with pickle PYQ part 2

What We'll Learn

A quick overview of today's lecture

Binary file operations with pickle PYQ part 2 PYQ PRACTICE SCOPE: Binary file operations with pickle. Concept ID: U1_BINARY_PICKLE_OPS. Use only previous-year questions whose concept_ids include U1_BINARY_PICKLE_OPS.
Key things we'll cover
Binary file operations with pickle
PYQ references used by both prompts 8 included 0 excluded
Flagged questions are excluded from both Study Notes and PPT references until corrected in Paper Analyzer.
Included ID 6326 · 2023 · 4 mark(s)
Atharva is a programmer, who has recently been given a task to write a Python code to perform the following binary file operation with the help of a user defined function/module : - Copy_new() : to create a binary file new_items.dat and write all the item details stored in the binary file, items.dat, except for the item whose item_id is 101. The data is stored in the following format : {item_id:[item_name,amount]} import ______ # Statement 1 def Copy_new(): f1= ______ # Statement 2 f2= ______ # Statement 3 item_id=int(input("Enter the item id")) item_detail= ______ # Statement 4 for key in item_detail: if ______: # Statement 5 pickle. ______ # Statement 6 f1.close() f2.close() He has succeeded in writing partial code and has missed out certain statements. Therefore, as a Python expert, help him to complete the code based on the given requirements : (i) Which module should be imported in the program ? (Statement 1) (ii) Write the correct statement required to open the binary file "items.dat". (Statement 2) (Option for part iii only) (iii) What should Atharva write in Statement 5 to apply the given condition and in Statement 6 to write data in the binary file "new_items.dat".
File Handling → Binary file operations with pickle
Included ID 6608 · 2023 · 5 mark(s)
(i) How are text files different from binary files? (ii) A Binary file, CINEMA.DAT has the following structure: {MNO:[MNAME, MTYPE]} Where MNO – Movie Number, MNAME – Movie Name, MTYPE is Movie Type. Write a user defined function, findType(mtype), that accepts mtype as parameter and displays all the records from the binary file CINEMA.DAT, that have the value of Movie Type as mtype.
File Handling → Binary file operations with pickle
Included ID 6171 · 2024 · 4 mark(s)
Write a program in Python to create a binary file Employee.dat and write the following data into it: Employee ID, Employee Name, Department, Salary
File Handling → Binary file operations with pickle
Included ID 6366 · 2024 · 5 mark(s)
(b) (i) Give one difference between write() and writeline() function in text file. (ii) A Binary file, "Items.dat" has the following structure : [Icode, Description, Price] Where Icode – Item code Description – Detail of item Price – Price of item Write a function Add_data(), that takes Icode, Description and Price from the user and writes the information in the binary file "Items.dat".
File Handling → Binary file operations with pickle
Included ID 6658 · 2024 · 5 mark(s)
Surya is a manager working in a recruitment agency. He needs to manage the records of various candidates. For this, he wants the following information of each candidate to be stored: - Candidate_ID – integer - Candidate_Name – string - Designation – string - Experience – float You, as a programmer of the company, have been assigned to do this job for Surya. (I) Write a function to input the data of a candidate and append it in a binary file. (II) Write a function to update the data of candidates whose experience is more than 10 years and change their designation to "Senior Manager". (III) Write a function to read the data from the binary file and display the data of all those candidates who are not "Senior Manager".
File Handling → Binary file operations with pickle
Included ID 6417 · 2025 · 5 mark(s)
Keshav is the IT Head in a hospital. He needs to manage the records of all the doctors in the hospital. For this, he wants to store the following information of each doctor in a file : D_ID – An integer to store Doctor ID. D_Name – A string to store doctor's name. D_Dept – A string to store the Department of the doctor. (Surgery, Radiology, etc.) Experience – An integer to store doctor's experience (in years) For example, a doctor's information may be : [1256, 'R. Gupta', 'Cardiology', 15] As an applicant for the post of a Programmer, you have to answer the following questions in this context : (I) Write one difference of storing this data in a binary file over a CSV file. (II) Assume that the data is stored in a binary file, named DOCTORS.DAT, and each record is stored as a list. Write a function, in Python, to read and display all the records from the file DOCTORS.DAT. (III) Write a function addDoctor(), in Python, which accepts a doctor's data from the user and writes it in the file DOCTORS.DAT.
File Handling → CSV file read write and search, Binary file operations with pickle
Included ID 6705 · 2025 · 5 mark(s)
Mr. Ravi, a manager at a tech company, needs to maintain records of employees. Each record should include: Employee_ID, Employee_Name, Department and Salary. Write the Python functions to: I. Input employee data and append it to a binary file. (2 marks) II. Update the salary of employees in the "IT" department to 200000. (3 marks)
File Handling → Binary file operations with pickle
Included ID 6265 · 2026 · 5 mark(s)
NextStep is an organization which has a pool of resource persons to conduct training workshops on various topics related to ICT. The data of all its Resource Persons is stored in a binary file RESOURCES.DAT using the following record structure (each record is a tuple) : (R_ID, R_Name, R_Expertise, Charges) where : · R_ID – Resource Person's ID (An integer) · R_Name – Resource Person's Name (A string) · R_Expertise – Area of expertise of the Resource Person · Charges – Charges (in rupees) per hour to conduct a workshop For example, a record in the file is : (12, 'P. Velusami', 'Machine Learning', 5000) In this context, write the following user defined functions in Python : (i) Append() – To input the data of a Resource Person and write it in the file RESOURCES.DAT. (ii) Update() – To increase the Charges of each resource person by 500.
File Handling → Binary file operations with pickle
.txt