Monday, 13 July 2026
Lecture 24 of 73 · Unit 1
Unit 1 ⏳ Pending
Unlocks at 05:00 PM, 13 Jul 2026

File basics, paths, modes, seek and tell PYQ part 1

What We'll Learn

A quick overview of today's lecture

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.
Key things we'll cover
File basics, paths, modes, seek and tell
PYQ references used by both prompts 14 included 0 excluded
Flagged questions are excluded from both Study Notes and PPT references until corrected in Paper Analyzer.
Included ID 6475 · 2021 · 1 mark(s)
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.
File Handling → File basics paths modes seek and tell
Included ID 6478 · 2021 · 1 mark(s)
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
File Handling → File basics paths modes seek and tell
Included ID 6483 · 2021 · 1 mark(s)
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
File Handling → File basics paths modes seek and tell
Included ID 6485 · 2021 · 1 mark(s)
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
File Handling → File basics paths modes seek and tell
Included ID 6518 · 2021 · 1 mark(s)
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
File Handling → File basics paths modes seek and tell
Included ID 6532 · 2022 · 1 mark(s)
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
File Handling → File basics paths modes seek and tell
Included ID 6537 · 2022 · 1 mark(s)
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)
File Handling → File basics paths modes seek and tell
Included ID 6092 · 2023 · 1 mark(s)
Which of the following mode keeps the file offset position at the end of the file ? (a) r+ (b) x (c) w (d) a
File Handling → File basics paths modes seek and tell
Included ID 6097 · 2023 · 1 mark(s)
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
File Handling → File basics paths modes seek and tell
Included ID 6289 · 2023 · 1 mark(s)
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
File Handling → File basics paths modes seek and tell
Included ID 6294 · 2023 · 1 mark(s)
The correct syntax of tell() is: (a) tell.file object () (b) file object.tell() (c) tell.file object (1) (d) file object.tell1(1)
File Handling → File basics paths modes seek and tell
Included ID 6584 · 2023 · 1 mark(s)
Which of the following functions changes the position of file pointer and returns its new position? a) flush() b) tell() c) seek() d) offset()
File Handling → File basics paths modes seek and tell
Included ID 6313 · 2023 · 3 mark(s)
(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
File Handling → File basics paths modes seek and tell
Included ID 6600 · 2023 · 3 mark(s)
Write a function in Python to read a text file, Alpha.txt and displays those lines which begin with the word 'You'.
File Handling → File basics paths modes seek and tell
.txt