Text file reading writing searching and counting PYQ part 3 — Lecture 30
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 30 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 9 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 3 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 3 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: Text file reading writing searching and counting | Year | Questions | Marks | |------|-----------|-------| | 2024 | 7 | 22 | | 2025 | 2 | 4 | | **Total** | **9** | **26** | =========================================== SECTION 4: ACTUAL PREVIOUS YEAR QUESTIONS (Scope: "Text file reading writing searching and counting" only — 9 questions from board papers) =========================================== PYQ LECTURE RULE: use these questions as the source pool for practice. - This pool has 9 questions: preserve and discuss ALL 9 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. --- 2024 Board Exam (7 questions | 22 marks) --- Q1. [Programming] [3M] [Medium] Section-C (a) Write the user defined function count_words() in Python to count the number of words in a text file "Story.txt". Q2. [Programming] [3M] [Medium] Section-C (b) Write the user defined function display() in Python to read the content of a text file "Story.txt" and display those words which are less than 4 characters. Q3. [Programming] [3M] [Medium] Section-C (a) Write a method/function COUNTWORDS() in Python to read contents from a text file DECODE.TXT, to count and return the occurrence of those words, which are having 5 or more characters. Q4. [Programming] [3M] [Medium] Section-C (b) Write a method/function COUNTLINES() in Python to read lines from a text file CONTENT.TXT, and display those lines, which have @ anywhere in the line. For example : If the content of the file is : Had an amazing time at the concert last night with @MusicLoversCrew. Excited to announce the launch of our new website! G20 @ India The method/function should display Had an amazing time at the concert last night with @MusicLoversCrew G20 @ India Q5. [Short Answer] [3M] [Medium] Section-C A) Write a Python function that displays all the words containing @cmail from a text file "Emails.txt". Q6. [Short Answer] [3M] [Medium] Section-C B) Write a Python function that finds and displays all the words longer than 5 characters from a text file "Words.txt". Q7. [Programming] [4M] [Medium] Section-E Write a program in Python to read the content of a text file Story.txt and count and display the number of lines that start with the letter 'A'. --- 2025 Board Exam (2 questions | 4 marks) --- Q1. [MCQ] [1M] [Easy] Section-A A text file 'song.txt' contains the following contents in it : Life goes on as it never ends What will be the output of the following code snippet ? f1=open("song.txt","r") s1=f1.read(5) s2=f1.readline(4) s3=f1.read(3) print(s1,s3,sep="#") (A) goes# on (B) Life #goes# on (C) Life # on (D) Error Q2. [Programming] [3M] [Medium] Section-C Write a user defined function in Python named COUNT() which counts and displays the number of lines which do not start with the vowels 'A' or 'E' in the file, "Paragraph.txt". =========================================== =========================================== 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: Text file reading writing searching and counting Pattern: MCQ=1, Programming=6, Short Answer=2 | Marks: 1M=1, 3M=7, 4M=1 | Total: 9 questions [Programming] [3M] [Medium] × 5 → 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 [Programming] [4M] [Medium] → Core concept of Text file reading writing searching and counting [MCQ] [1M] [Easy] → Output/result interpretation for the current concept =========================================== =========================================== 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 | 68 | 9 | 26M | 2025, 2024 | CRITICAL | 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 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