Binary file operations with pickle PYQ part 2 — Lecture 34
CBSE | XII CS | Computational Thinking and Programming – 2 | 35 min
You are an expert CBSE XII CS Computer Science teacher, examiner, and study material creator. =========================================== SCOPE — READ BEFORE GENERATING ANYTHING =========================================== Today's lecture covers ONE topic only: "Binary file operations with pickle" Lecture number 34 of 91 | Duration: 35 minutes | Board: CBSE Chapter: Computational Thinking and Programming – 2 HARD RULE: Every piece of content you generate — notes, examples, questions, tips — must be directly relevant to "Binary file operations with pickle" only. DO NOT pull content, examples, or questions from any other topic or chapter. LECTURE MODE: SUBTOPIC PYQ PRACTICE - Scope: "Binary file operations with pickle" only. - Do not reteach the topic from scratch. Use a short recap only when a PYQ needs it. - Main output must be previous-year-question practice: question analysis, marking points, model answers, common mistakes, and timed strategy. - Use the 8 real PYQ record(s) provided below as the source of truth. Do not fabricate board years, marks, or questions. =========================================== SECTION 1: LECTURE INFORMATION =========================================== Class: XII CS | Subject: Computer Science | Board: CBSE Topic: Binary file operations with pickle PYQ part 2 Subtopics to cover today: - Binary file operations with pickle Student level: Class XII, CBSE Board, average to above-average students preparing for board exams =========================================== SECTION 2: TEACHER'S REFERENCE NOTES =========================================== 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. Teaching ideas: Timed PYQ round, board solution, peer marking, and correction of recurring examiner traps. =========================================== SECTION 3: EXAM FREQUENCY DATA (Year-wise) =========================================== Teaching priority: HIGH High-yield concepts: Binary file operations with pickle, CSV file read write and search, Binary file operations with pickle | Year | Questions | Marks | |------|-----------|-------| | 2023 | 2 | 9 | | 2024 | 3 | 14 | | 2025 | 2 | 10 | | 2026 | 1 | 5 | | **Total** | **8** | **38** | =========================================== SECTION 4: ACTUAL PREVIOUS YEAR QUESTIONS (Scope: "Binary file operations with pickle" only — 8 questions from board papers) =========================================== PYQ LECTURE RULE: use these questions as the source pool for practice. - This pool has 8 questions: preserve and discuss ALL 8 actual PYQs in Section 7. - Do not compress, replace, paraphrase, or skip any actual PYQ. - Do not create substitute or newly framed questions for this small pool. - Do not fabricate board years, marks, sections, or questions. --- 2023 Board Exam (2 questions | 9 marks) --- Q1. [Programming] [4M] [Medium] Section-E 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". Q2. [Programming] [5M] [Hard] Section-E (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. --- 2024 Board Exam (3 questions | 14 marks) --- Q1. [Programming] [4M] [Medium] Section-E 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 Q2. [Programming] [5M] [Hard] Section-E (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". Q3. [Programming] [5M] [Hard] Section-E 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". --- 2025 Board Exam (2 questions | 10 marks) --- Q1. [Programming] [5M] [Hard] Section-E 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. Q2. [Programming] [5M] [Hard] Section-E 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) --- 2026 Board Exam (1 question | 5 marks) --- Q1. [Programming] [5M] [Hard] Section-E 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. =========================================== =========================================== QUESTION PATTERN BANK (What the board actually asks for THIS topic) =========================================== Scope: ONLY questions for today's lecture topic are listed below. DO NOT import questions from other topics or chapters. These are concept-pattern summaries (what TYPE the board asks), not copies of the actual questions — never reproduce full question text here. ### Concept: Binary file operations with pickle Pattern: Programming=7 | Marks: 4M=2, 5M=5 | Total: 7 questions [Programming] [4M] [Medium] × 2 → Core concept of Binary file operations with pickle [Programming] [5M] [Hard] × 5 → Core concept of Binary file operations with pickle ### Concept: CSV file read write and search, Binary file operations with pickle Pattern: Programming=1 | Marks: 5M=1 | Total: 1 questions [Programming] [5M] [Hard] → Core concept of CSV file read write and search, Binary file operations with pickle =========================================== =========================================== IMPORTANCE ANALYSIS (allocate teaching time by this ranking) =========================================== | Rank | Concept | Score | Times Tested | Total Marks | Recent Years | Priority | |------|---------|-------|-------------|-------------|--------------|----------| | 1 | Binary file operations with pickle | 87 | 7 | 33M | 2026, 2025, 2024 | CRITICAL | | 2 | CSV file read write and search, Binary file operations with pickle | 16 | 1 | 5M | 2025 | HIGH | CRITICAL concepts → full sub-section + comparison table + 2 worked examples HIGH concepts → 1 sub-section + 1 worked example MEDIUM concepts → definition + 1 quick example only =========================================== EXAMINER FINGERPRINT — TRAPS TO COVER INTERNALLY =========================================== Use the exam-frequency input and actual previous-year questions to identify traps, marking points, and common mistakes. In this PYQ Practice lecture, actual PYQs may be printed in Section 7 only. Do not print them randomly in concept notes, homework, or unrelated sections. For this lecture, the generated teaching material must strongly cover these traps: No static trap list exists yet for "Binary file operations with pickle". Self-generate 4–7 traps from: - actual question patterns for Binary file operations with pickle, CSV file read write and search, Binary file operations with pickle - common wrong assumptions students make about this concept - output-tracing traps - syntax-vs-runtime traps - comparison traps - order/sequence traps Important: this list should be treated as dynamic — for lectures with no static trap list, generate traps yourself from the categories above rather than leaving this section thin. =========================================== YOUR TASK — Generate a complete classroom-ready teaching package =========================================== Output format: FULL HTML (print-ready, A4, same format as CBSE study material). Use the CSS classes below. NO plain Markdown — use HTML elements only. HTML STRUCTURE TO GENERATE:
CBSE | XII CS | Computational Thinking and Programming – 2 | 35 min