Binary file operations with pickle PYQ part 3 — Lecture 35
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 35 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 7 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 3 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 3 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: CSV file read write and search, Binary file operations with pickle, File basics paths modes seek and tell, Binary file operations with pickle | Year | Questions | Marks | |------|-----------|-------| | 2021 | 2 | 2 | | 2022 | 1 | 5 | | 2023 | 1 | 5 | | 2024 | 1 | 5 | | 2025 | 1 | 1 | | 2026 | 1 | 1 | | **Total** | **7** | **19** | =========================================== SECTION 4: ACTUAL PREVIOUS YEAR QUESTIONS (Scope: "Binary file operations with pickle" only — 7 questions from board papers) =========================================== PYQ LECTURE RULE: use these questions as the source pool for practice. - This pool has 7 questions: preserve and discuss ALL 7 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. --- 2021 Board Exam (2 questions | 2 marks) --- Q1. [MCQ] [1M] [Easy] Section-A Which of the following statement opens a binary file record.bin in write mode and writes data from a list lst1 = [1,2,3,4] on the binary file? a) with open('record.bin','wb') as myfile: pickle.dump(lst1,myfile) b) with open('record.bin','wb') as myfile: pickle.dump(myfile,lst1) c) with open('record.bin','wb+') as myfile: pickle.dump(myfile,lst1) d) with open('record.bin','ab') as myfile: pickle.dump(myfile,lst1) Q2. [MCQ] [1M] [Easy] Section-C Choose the function name that should be used in the blank space of line marked as Statement-6 to create the desired CSV File. (Refer to the CSV file creation code in the case study: stuwriter._____(data)) a) dump() b) load() c) writerows() d) writerow() --- 2022 Board Exam (1 question | 5 marks) --- Q1. [Programming] [5M] [Hard] Section-D Give any one point of difference between a binary file and a csv file. Write a Program in Python that defines and calls the following user defined functions: (i) add() – To accept and add data of an employee to a CSV file 'furdata.csv'. Each record consists of a list with field elements as fid, fname and fprice to store furniture id, furniture name and furniture price respectively. (ii) search() – To display the records of the furniture whose price is more than 10000. --- 2023 Board Exam (1 question | 5 marks) --- Q1. [Programming] [5M] [Hard] Section-E (i) Differentiate between r+ and w+ file modes in Python. (ii) Consider a file, SPORT.DAT, containing records of the following structure: [SportName, TeamName, No_Players] Write a function, copyData(), that reads contents from the file SPORT.DAT and copies the records with Sport name as "Basket Ball" to the file named BASKET.DAT. The function should return the total number of records copied to the file BASKET.DAT. (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 (1 question | 5 marks) --- Q1. [Programming] [5M] [Hard] Section-E (a) (i) What is the main purpose of seek() and tell() method ? (ii) Consider a binary file, Cinema.dat containing information in the following structure : [Mno, Mname, Mtype] Write a function, search_copy(), that reads the content from the file Cinema.dat and copies all the details of the "Comedy" movie type to file named movie.dat. (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". --- 2025 Board Exam (1 question | 1 marks) --- Q1. [Assertion-Reason] [1M] [Easy] Section-A Assertion (A): For a binary file opened using 'rb' mode, the pickle.dump() method will display an error. Reason (R): The pickle.dump() method is used to read from a binary file. (A) Both Assertion (A) and Reason (R) are true and Reason (R) is the correct explanation for Assertion (A). (B) Both Assertion (A) and Reason (R) are true and Reason (R) is not the correct explanation for Assertion (A). (C) Assertion (A) is true but Reason (R) is false. (D) Assertion (A) is false but Reason (R) is true. --- 2026 Board Exam (1 question | 1 marks) --- Q1. [MCQ] [1M] [Easy] Section-A Consider the statement given below : f1 = open("pqr.dat","_______") Which of the following is the correct file mode to open the file in read only mode ? (A) a (B) rb (C) r+ (D) rb+ =========================================== =========================================== 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: CSV file read write and search, Binary file operations with pickle Pattern: MCQ=1, Programming=1 | Marks: 1M=1, 5M=1 | Total: 2 questions [MCQ] [1M] [Easy] → Core concept of CSV file read write and search, Binary file operations with pickle [Programming] [5M] [Hard] → Core concept of CSV file read write and search, Binary file operations with pickle ### Concept: File basics paths modes seek and tell, Binary file operations with pickle Pattern: Assertion-Reason=1, MCQ=2, Programming=2 | Marks: 1M=3, 5M=2 | Total: 5 questions [MCQ] [1M] [Easy] × 2 → Core concept of File basics paths modes seek and tell, Binary file operations with pickle [Programming] [5M] [Hard] × 2 → Core concept of File basics paths modes seek and tell, Binary file operations with pickle [Assertion-Reason] [1M] [Easy] → Core concept of File basics paths modes seek and tell, Binary file operations with pickle =========================================== =========================================== IMPORTANCE ANALYSIS (allocate teaching time by this ranking) =========================================== | Rank | Concept | Score | Times Tested | Total Marks | Recent Years | Priority | |------|---------|-------|-------------|-------------|--------------|----------| | 1 | File basics paths modes seek and tell, Binary file operations with pickle | 45 | 5 | 13M | 2026, 2025, 2024 | CRITICAL | | 2 | CSV file read write and search, Binary file operations with pickle | 14 | 2 | 6M | 2022, 2021 | 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 CSV file read write and search, Binary file operations with pickle, File basics paths modes seek and tell, 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