Text file reading writing searching and counting PYQ part 4 — Lecture 31
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: "Text file reading writing searching and counting" Lecture number 31 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 "Text file reading writing searching and counting" only. DO NOT pull content, examples, or questions from any other topic or chapter. LECTURE MODE: SUBTOPIC PYQ PRACTICE - Scope: "Text file reading writing searching and counting" 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: Text file reading writing searching and counting PYQ part 4 Subtopics to cover today: - Text file reading writing searching and counting Student level: Class XII, CBSE Board, average to above-average students preparing for board exams =========================================== SECTION 2: TEACHER'S REFERENCE NOTES =========================================== Text file reading writing searching and counting PYQ part 4 PYQ PRACTICE SCOPE: Text file reading writing searching and counting. Concept ID: U1_TEXT_FILE_OPERATIONS. Use only previous-year questions whose concept_ids include U1_TEXT_FILE_OPERATIONS. 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, Text file reading writing searching and counting, File basics paths modes seek and tell, Text file reading writing searching and counting, Text file reading writing searching and counting | Year | Questions | Marks | |------|-----------|-------| | 2023 | 1 | 5 | | 2024 | 2 | 6 | | 2025 | 3 | 9 | | 2026 | 2 | 6 | | **Total** | **8** | **26** | =========================================== SECTION 4: ACTUAL PREVIOUS YEAR QUESTIONS (Scope: "Text file reading writing searching and counting" 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 (1 question | 5 marks) --- Q1. [Programming] [5M] [Hard] Section-D (a) Write one difference between CSV and text files. Write a program in Python that defines and calls the following user defined functions : (i) COURIER_ADD(): It takes the values from the user and adds the details to a csv file 'courier.csv'. Each record consists of a list with field elements as cid, s_name, Source, destination to store Courier ID, Sender name, Source and destination address respectively. (ii) COURIER_SEARCH() : Takes the destination as the input and displays all the courier records going to that destination. (ii) Search_Book(): Takes publisher name as input and counts and displays number of books published by them. --- 2024 Board Exam (2 questions | 6 marks) --- Q1. [MCQ] [1M] [Easy] Section-A Which of the following file opening mode is used to open a file in append and read mode ? (A) r+ (B) w+ (C) a+ (D) x+ 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". --- 2025 Board Exam (3 questions | 9 marks) --- Q1. [Programming] [3M] [Medium] Section-C (b) Write a function in Python to display the line which has the maximum number of vowels from a text file, "Novel.txt" Q2. [Programming] [3M] [Medium] Section-C A. Write a Python function that displays the number of times the word "Python" appears in a text file named "Prog.txt". Q3. [Programming] [3M] [Medium] Section-C B. Write and call a Python function to read lines from a text file STORIES.TXT and display those lines which doesn't start with a vowel (A, E, I, O, U) irrespective of their case. --- 2026 Board Exam (2 questions | 6 marks) --- Q1. [Short Answer] [3M] [Medium] Section-C (a) Write a Python function that counts and returns the number of digits appearing in the text file "Space.txt". For example, if the file contains : Space exploration has unlocked incredible advancements in technology and science. Since the first moon landing in 1969, space agencies have sent probes to Mars, Jupiter and beyond. The ISS, orbiting Earth at about 400 km, serves as a hub for research. With missions planned for 2030, humanity's cosmic journey continues! Then the function should return 11. Q2. [Short Answer] [3M] [Medium] Section-C (b) Write a Python function that displays the words in which the lowercase letter 'e' appears at least twice in the text file 'Space.txt'. For example, if the file contains : Space exploration has unlocked incredible advancements in technology and science. Since the first moon landing in 1969, space agencies have sent probes to Mars, Jupiter and beyond. The ISS, orbiting Earth at about 400 km, serves as a hub for research. With missions planned for 2030, humanity's cosmic journey continues! Then the function should display : incredible advancements science. agencies serves research. =========================================== =========================================== 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=1 | Marks: 5M=1 | Total: 1 questions [Programming] [5M] [Hard] → Core concept of Binary file operations with pickle ### Concept: CSV file read write and search, Text file reading writing searching and counting Pattern: Programming=1 | Marks: 5M=1 | Total: 1 questions [Programming] [5M] [Hard] → Core concept of CSV file read write and search, Text file reading writing searching and counting ### Concept: File basics paths modes seek and tell, Text file reading writing searching and counting Pattern: MCQ=1 | Marks: 1M=1 | Total: 1 questions [MCQ] [1M] [Easy] → Core concept of File basics paths modes seek and tell, Text file reading writing searching and counting ### Concept: Text file reading writing searching and counting Pattern: Programming=3, Short Answer=2 | Marks: 3M=5 | Total: 5 questions [Programming] [3M] [Medium] × 3 → Core concept of Text file reading writing searching and counting [Short Answer] [3M] [Medium] × 2 → Core concept of Text file reading writing searching and counting =========================================== =========================================== IMPORTANCE ANALYSIS (allocate teaching time by this ranking) =========================================== | Rank | Concept | Score | Times Tested | Total Marks | Recent Years | Priority | |------|---------|-------|-------------|-------------|--------------|----------| | 1 | Text file reading writing searching and counting | 45 | 5 | 15M | 2026, 2025 | CRITICAL | | 2 | CSV file read write and search, Text file reading writing searching and counting | 13 | 1 | 5M | 2023 | HIGH | | 3 | Binary file operations with pickle | 13 | 1 | 5M | 2024 | HIGH | | 4 | File basics paths modes seek and tell, Text file reading writing searching and counting | 5 | 1 | 1M | 2024 | MEDIUM | 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 "Text file reading writing searching and counting". Self-generate 4–7 traps from: - actual question patterns for Binary file operations with pickle, CSV file read write and search, Text file reading writing searching and counting, File basics paths modes seek and tell, Text file reading writing searching and counting, Text file reading writing searching and counting - 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