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
Syntax for opening Student.csv file in write mode is myfile = open("Student.csv","w",newline='').
What is the importance of newline=''?
a) A newline gets added to the file
b) Empty string gets appended to the first line.
c) Empty string gets appended to all lines.
d) EOL translation is suppressed
File Handling
→ File basics paths modes seek and tell, CSV file read write and search
· Concept U1_FILE_BASICS_MODES;U1_CSV_OPS
Included in reference
ID 6495 · 2021 · 1 mark(s)
Which of the following statement opens a binary file record.bin in write mode and writes data from a list lst1 = [1,2,3,4] on the binary file?
a) with open('record.bin','wb') as myfile:
pickle.dump(lst1,myfile)
b) with open('record.bin','wb') as myfile:
pickle.dump(myfile,lst1)
c) with open('record.bin','wb+') as myfile:
pickle.dump(myfile,lst1)
d) with open('record.bin','ab') as myfile:
pickle.dump(myfile,lst1)
File Handling
→ File basics paths modes seek and tell, Binary file operations with pickle
· Concept U1_FILE_BASICS_MODES;U1_BINARY_PICKLE_OPS
Included in reference
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
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
(a) Write a point of difference between append (a) and write (w) modes in a text file.
Write a program in Python that defines and calls the following user defined functions :
(i) Add_Teacher() : It accepts the values from the user and inserts record of a teacher to a csv file "Teacher.csv". Each record consists of a list with field elements as T_id, Tname and desig to store teacher ID, teacher name and designation respectively.
(ii) Search_Teacher() : To display the records of all the PGT (designation) teachers.
(ii) Count_Device() : To count and display number of peripheral devices, whose price is less than or equal to 1000.
(b) Write one point of difference between seek() and tell() functions in file handling.
Write a program in Python that defines and calls the following user defined functions :
(i) Add_Device() : The function accepts and adds records of the peripheral devices to a csv file 'peripheral.csv'. Each record consists of a list with field elements as P_id, P_name and Price to store peripheral device ID, device name, and price respectively.
(ii) Count_Device() : To count and display number of peripheral devices, whose price is less than or equal to 1000.
File Handling
→ File basics paths modes seek and tell, CSV file read write and search
· Concept U1_FILE_BASICS_MODES;U1_CSV_OPS
Included in reference
ID 6607 · 2023 · 5 mark(s)
(i) Differentiate between r+ and w+ file modes in Python.
(ii) Consider a file, SPORT.DAT, containing records of the following structure:
[SportName, TeamName, No_Players]
Write a function, copyData(), that reads contents from the file SPORT.DAT and copies the records with Sport name as "Basket Ball" to the file named BASKET.DAT. The function should return the total number of records copied to the file BASKET.DAT.
(ii) A Binary file, CINEMA.DAT has the following structure:
{MNO:[MNAME, MTYPE]}
Where MNO – Movie Number, MNAME – Movie Name, MTYPE is Movie Type.
Write a user defined function, findType(mtype), that accepts mtype as parameter and displays all the records from the binary file CINEMA.DAT, that have the value of Movie Type as mtype.
File Handling
→ File basics paths modes seek and tell, Binary file operations with pickle
· Concept U1_FILE_BASICS_MODES;U1_BINARY_PICKLE_OPS
Included in reference
ID 6143 · 2024 · 1 mark(s)
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+
File Handling
→ File basics paths modes seek and tell, Text file reading writing searching and counting
· Concept U1_FILE_BASICS_MODES;U1_TEXT_FILE_OPERATIONS
Included in reference
ID 6161 · 2024 · 3 mark(s)
Write the user defined function Modify() to read a text file "data.txt" and replace all the occurrences of "COmputer" with "Computer" and display all the lines on screen.
(a) (i) What is the main purpose of seek() and tell() method ?
(ii) Consider a binary file, Cinema.dat containing information in the following structure :
[Mno, Mname, Mtype]
Write a function, search_copy(), that reads the content from the file Cinema.dat and copies all the details of the "Comedy" movie type to file named movie.dat.
(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".
File Handling
→ File basics paths modes seek and tell, Binary file operations with pickle
· Concept U1_FILE_BASICS_MODES;U1_BINARY_PICKLE_OPS
Included in reference
ID 6192 · 2025 · 1 mark(s)
Assertion (A): For a binary file opened using 'rb' mode, the pickle.dump() method will display an error.
Reason (R): The pickle.dump() method is used to read from a binary file.
(A) Both Assertion (A) and Reason (R) are true and Reason (R) is the correct explanation for Assertion (A).
(B) Both Assertion (A) and Reason (R) are true and Reason (R) is not the correct explanation for Assertion (A).
(C) Assertion (A) is true but Reason (R) is false.
(D) Assertion (A) is false but Reason (R) is true.
File Handling
→ File basics paths modes seek and tell, Binary file operations with pickle
· Concept U1_FILE_BASICS_MODES;U1_BINARY_PICKLE_OPS
Included in reference
ID 6405 · 2025 · 3 mark(s)
(a) Write a Python function that displays all the lines ending with a dot (.) from a text file, "Colors.txt". For example, if the file "Colors.txt" contains :
White is a mix of seven colors.
What are these seven colors ?
VIBGYOR – violet, indigo, blue, green, orange and red.
When we mix all these colors we just get one light which is the WHITE light.
Then the output should be :
White is a mix of seven colors.
VIBGYOR – violet, indigo, blue, green, orange and red.
which is the WHITE light.
(Hint : You will have to ignore trailing white spaces to check the last character)
A. Write a Python function that displays the number of times the word "Python" appears in a text file named "Prog.txt".
File Handling
→ Text file reading writing searching and counting
· Concept U1_FILE_BASICS_MODES;U1_TEXT_FILE_OPERATIONS
Included in reference
ID 6217 · 2025 · 4 mark(s)
Write a program in Python to create a text file MARKS.TXT and write the names of all those students and their total marks obtained in Physics, Chemistry and Maths whose total marks are greater than 220.
Consider the statement given below :
f1 = open("pqr.dat","_______")
Which of the following is the correct file mode to open the file in read only mode ?
(A) a
(B) rb
(C) r+
(D) rb+
File Handling
→ File basics paths modes seek and tell, Binary file operations with pickle
· Concept U1_FILE_BASICS_MODES;U1_BINARY_PICKLE_OPS
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.