File basics, paths, modes, seek and tell PYQ part 1 — Lecture 24
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: "File basics, paths, modes, seek and tell" Lecture number 24 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 "File basics, paths, modes, seek and tell" only. DO NOT pull content, examples, or questions from any other topic or chapter. LECTURE MODE: SUBTOPIC PYQ PRACTICE - Scope: "File basics, paths, modes, seek and tell" 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 14 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: File basics, paths, modes, seek and tell PYQ part 1 Subtopics to cover today: - File basics, paths, modes, seek and tell Student level: Class XII, CBSE Board, average to above-average students preparing for board exams =========================================== SECTION 2: TEACHER'S REFERENCE NOTES =========================================== File basics, paths, modes, seek and tell PYQ part 1 PYQ PRACTICE SCOPE: File basics, paths, modes, seek and tell. Concept ID: U1_FILE_BASICS_MODES. Use only previous-year questions whose concept_ids include U1_FILE_BASICS_MODES. 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: File basics paths modes seek and tell | Year | Questions | Marks | |------|-----------|-------| | 2021 | 5 | 5 | | 2022 | 2 | 2 | | 2023 | 7 | 11 | | **Total** | **14** | **18** | =========================================== SECTION 4: ACTUAL PREVIOUS YEAR QUESTIONS (Scope: "File basics, paths, modes, seek and tell" only — 14 questions from board papers) =========================================== PYQ LECTURE RULE: use these questions as the source pool for practice. - This pool has 14 questions: preserve and discuss ALL 14 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 (5 questions | 5 marks) --- Q1. [MCQ] [1M] [Easy] Section-A Which of the following option is not correct? a) if we try to read a text file that does not exist, an error occurs. b) if we try to read a text file that does not exist, the file gets created. c) if we try to write on a text file that does not exist, no error occurs. d) if we try to write on a text file that does not exist, the file gets created. Q2. [MCQ] [1M] [Easy] Section-A A text file student.txt is stored in the storage device. Identify the correct option out of the following options to open the file in read mode. i. myfile = open('student.txt','rb') ii. myfile = open('student.txt','w') iii. myfile = open('student.txt','r') iv. myfile = open('student.txt') a) only i b) both i and iv c) both iii and iv d) both i and iii Q3. [MCQ] [1M] [Easy] Section-A What is the significance of the tell() method? a) tells the path of file b) tells the current position of the file pointer within the file c) tells the end position within the file d) checks the existence of a file at the desired location Q4. [MCQ] [1M] [Easy] Section-A Syntax of seek function in Python is myfile.seek(offset, reference_point) where myfile is the file object. What is the default value of reference_point? a) 0 b) 1 c) 2 d) 3 Q5. [MCQ] [1M] [Easy] Section-B Consider the following directory structure. (Root: School → Subdirectories: Academics [contains Syllabus.jpg], Examination [contains Result.png], Sports [contains Achievement.jpg]) Suppose root directory (School) and present working directory are the same. What will be the absolute path of the file Syllabus.jpg? a) School/syllabus.jpg b) School/Academics/syllabus.jpg c) School/Academics/../syllabus.jpg d) School/Examination/syllabus.jpg --- 2022 Board Exam (2 questions | 2 marks) --- Q1. [MCQ] [1M] [Easy] Section-A Which of the following mode in file opening statement results or generates an error if the file does not exist? a) a+ b) r+ c) w+ d) None of the above Q2. [MCQ] [1M] [Easy] Section-A The correct syntax of seek() is: a) file_object.seek(offset [, reference_point]) b) seek(offset [, reference_point]) c) seek(offset, file_object) d) seek.file_object(offset) --- 2023 Board Exam (7 questions | 11 marks) --- Q1. [MCQ] [1M] [Easy] Section-A Which of the following mode keeps the file offset position at the end of the file ? (a) r+ (b) x (c) w (d) a Q2. [MCQ] [1M] [Easy] Section-A The syntax of seek( ) is file object.seek(offset[,reference point] ) What is the default value of reference point ? (a) 0 (b) 1 (c) 2 (d) 3 Q3. [MCQ] [1M] [Easy] Section-A Which of the following modes in Python creates a new file, if file does not exist and overwrites the content, if the file exists ? (a) r+ (b) r (c) w (d) a Q4. [MCQ] [1M] [Easy] Section-A The correct syntax of tell() is: (a) tell.file object () (b) file object.tell() (c) tell.file object (1) (d) file object.tell1(1) Q5. [MCQ] [1M] [Easy] Section-A Which of the following functions changes the position of file pointer and returns its new position? a) flush() b) tell() c) seek() d) offset() Q6. [Programming] [3M] [Medium] Section-C (a) Write a function in Python that displays the book names having 'Y' or 'y' in their name from a text file "Bookname.txt". Example : If the file 'Bookname.txt' contains the names of following books : One Hundred Years of Solitude The Diary of a Young Girl On the Road After execution, the output will be : One Hundred Years of Solitude The Diary of a Young Girl Q7. [Programming] [3M] [Medium] Section-C Write a function in Python to read a text file, Alpha.txt and displays those lines which begin with the word 'You'. =========================================== =========================================== 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: File basics paths modes seek and tell Pattern: MCQ=12, Programming=2 | Marks: 1M=12, 3M=2 | Total: 14 questions [MCQ] [1M] [Easy] × 8 → Core concept of File basics paths modes seek and tell [MCQ] [1M] [Easy] × 4 → Exception can occur even when syntax is correct [Programming] [3M] [Medium] → Output/result interpretation for the current concept [Programming] [3M] [Medium] → Core concept of File basics paths modes seek and tell =========================================== =========================================== 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 | 52 | 14 | 18M | 2023, 2022, 2021 | 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 "File basics, paths, modes, seek and tell". Self-generate 4–7 traps from: - actual question patterns for File basics paths modes seek and tell - 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