File basics, paths, modes, seek and tell PYQ part 1
File basics, paths, modes, seek and tell
PYQ reference preview14 included0 excluded
Review every matched question before generating. Flag a wrongly categorised question to
quarantine it from both study and PPT prompts until it is corrected in CBSE Paper Analyzer.
Included in reference
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.
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
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
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
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
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)
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
(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
Pick a lecture from the panel on the left, configure the board and student level,
then click Generate Prompt. The result includes PYQ data,
frequency analysis, exam trends, and a full 15-section teaching package request —
ready to paste into any AI assistant.
ChatGPTClaudeGeminiDeepSeek
PYQ Analysis
Frequency, marks & high-yield concepts
Lecture Flow
Exact time-allocation plan
15 Sections
From objectives to ranked exam questions
Export
Copy or download as .txt
Reset All Progress?
This will clear all Done and Missed marks and rebuild the schedule from scratch.
A backup will be created automatically before resetting. You can restore it from the Backups page.