CUET-UG SERIES
Computer-science

File Handling In Python

19 previous year questions.

Volume: 19 Ques
Yield: Medium

High-Yield Trend

6
2025
4
2024
9
2023

Chapter Questions
19 MCQs

01
PYQ 2023
medium
computer-science ID: cuet-ug-
Match List I with List II
LIST ILIST II
A. write linesIII. Writing a sequence of string
B. pickleI. Module for binary files
C. try-exceptIV. Exception handling
D. rbII. Opening and reading a binary file
1
A-III, B-IV, C-II, D-I
2
A-IV, B-I, C-III, D-II
3
A-III, B-IV, C-I, D-II
4
A-III, B-I, C-IV, D-II
02
PYQ 2023
medium
computer-science ID: cuet-ug-
Which of the following represents the mode of both writing and reading in binary format in a file?
1
wb+
2
w
3
a+
4
w+
03
PYQ 2023
medium
computer-science ID: cuet-ug-
Which of the following is not a valid mode to open a file?
1
ab
2
rw
3
r+
4
w+
04
PYQ 2023
medium
computer-science ID: cuet-ug-
Which error is generated by pickle.load() function when you reach end-of-file while reading from the file?
1
EOL error
2
EOF error
3
File doesn't exist
4
No error is generated
05
PYQ 2023
medium
computer-science ID: cuet-ug-
Which of the file modes in the following is invalid for a text-file?
1
a
2
w
3
r
4
ab
06
PYQ 2023
medium
computer-science ID: cuet-ug-
Which offset of the seek() method in the following is not valid?
1
0 - is for the beginning of the file.
2
1 - the middle position of the file.
3
2 - for the end of the file.
4
1 - for the current position of file pointer.
07
PYQ 2023
medium
computer-science ID: cuet-ug-
seek(1) method in files used for:
1
Sets the file's current position at the offset
2
Sets the file's previous position at the offset
3
Sets the file's current position within the file
4
Tells you the file is opened or not
08
PYQ 2023
medium
computer-science ID: cuet-ug-
Which of the following statements are true with respect to append \textless a\textgreater\ mode?
A. The user can read the file in \textless a\textgreater\ mode.
B. If the file is opened in \textless a\textgreater\ mode and the file doesn’t exist, then it will create a new file.
C. The user can write at the end of existing file when file is opened in \textless a\textgreater\ mode.
D. \textless a\textgreater\ mode is the default mode.
E. If the file is opened in \textless a\textgreater\ mode, the file offset position returned in the End of the file.
Choose the correct answer from the options given below:
1
A, B and C only
2
A, B, C and E only
3
A, B and D only
4
B, C and E only
12
PYQ 2024
medium
computer-science ID: cuet-ug-
Consider the following code and specify the correct order of the statements to be written:
Code:
(A) f.write(”CUET EXAMINATION”)
(B) f=open(”CUET.TXT”, ”w”)
(C) print(”Data is Written Successfully”)
(D) f.close()
Choose the correct answer from the options given below:
1
(A), (B), (C), (D)
2
(B), (A), (C), (D)
3
(B), (D), (C), (A)
4
(B), (D), (A), (C)