CUET Computer/IP: Computer ScienceFile Handling. Free, no login required.

Q1:

2026: 31 May Shift 1

File Handling

Easy

Computer Science

The process of converting a python object for writing into a binary file is called____.

Answer options
Option 2
Correct Answer
Explanation for 2026: 31 May Shift 1 CSE question 1

Q2:

2026: 31 May Shift 1

File Handling

Easy

Computer Science

Match the LIST-I with LIST-II

LIST-ILIST-II
A.write()I.Used to read a specified number of bytes (n) of data from a data file
B.readlines()II.Reads all lines and returns a line along new line character as list of strings
C.read()III.Takes a string as an argument and writes to the text file
D.writelines()IV.Used to write multiple strings to a file
Answer options
Option 2
Correct Answer
Explanation for 2026: 31 May Shift 1 CSE question 2

Q3:

2026: 29 May Shift 2

File Handling

Easy

Computer Science

The pickle module provides two methods to work with binary files. They are:

A. load()

B. unload()

C. dump()

D. clean()

Answer options
Option 2
Correct Answer
Explanation for 2026: 29 May Shift 2 CSE question 3

Q4:

2026: 29 May Shift 1

File Handling

Easy

Computer Science

Arrange the statements in order to write the record of a student (roll_no, name, gender and marks) in the binary file named mybinary.dat. (Assume pickle module is imported)

(A) pickle.dump(listvalues,fileobject)

(B) fileobject=open("mybinary.dat", "wb")

(C) fileobject.close()

(D) listvalues=[1,"Geetika",'F', 26]

Answer options
Option 1
Correct Answer
Explanation for 2026: 29 May Shift 1 CSE question 4

Q5:

2026: 29 May Shift 1

File Handling

Medium

Computer Science

Match List-I with List-II

List-I - CommandList-II - Explanation
(A) fileobject=open("test.txt","r+")(I) Opens the file in binary and read-only mode.
(B) fileobject=open("test.txt","+a")(II) Opens the file in read,write and binary mode. If the file already exists, the contents will be overwritten. If the file doesn’t exist, then a new file will be created.
(C) fileobject=open("test.dat","+wb")(III) Opens the file in append and read mode. If the file doesn’t exist, then it will create a new file.
(D) fileobject=open("test.dat","rb")(IV) Opens the file in both read and write mode.
Answer options
Option 1
Correct Answer
Explanation for 2026: 29 May Shift 1 CSE question 5

Q6:

2026: 26 May Shift 1

File Handling

Easy

Computer Science

The statement fileobject.seek(10,0) will __________.

Answer options
Option 2
Correct Answer
Explanation for 2026: 26 May Shift 1 CSE question 6

Q7:

2026: 24 May Shift 1

File Handling

Easy

Computer Science

Which of the following methods is used to position a file object to a specific position in a file?

Answer options
Option 4
Correct Answer
Explanation for 2026: 24 May Shift 1 CSE question 7

Q8:

2026: 24 May Shift 1

File Handling

Easy

Computer Science

Arrange the following statements in the correct sequence in order to write multiple strings to a file.

(A) myobj.close()

(B) lines= ["Hello everyone \n", "writing multiple strings into file"]

(C) myobj.writelines(lines)

(D) myobj = open ("myfile.txt", 'w')

Answer options
Option 1
Correct Answer
Explanation for 2026: 24 May Shift 1 CSE question 8

Q9:

2026: 23 May Shift 2

File Handling

Easy

Computer Science

When the byte stream is converted back to Python object, it is known as _______________.

Answer options
Option 1
Correct Answer
Explanation for 2026: 23 May Shift 2 CSE question 9

Q10:

2026: 23 May Shift 1

File Handling

Medium

Computer Science

Arrange the following in correct order:

A. listvalues=['abc', 'Gen', 1, 2.4]

B. pickle.load(fileobject)

C. fileobject = open("file.dat","wb")

D. pickle.dump(listvalues, fileobject)

Answer options

Q11:

2026: 23 May Shift 1

File Handling

Easy

Computer Science

How do you move the file pointer to the 10th10^{\text{th}} byte from the beginning of a file in Python?

Answer options

Q12:

2026: 21 May Shift 1

File Handling

Easy

Computer Science

Arrange the following code segment to read a binary file in the correct order.

(A) import pickle

(B) obj=pickle.load(fileobj)

(C) fileobj=open("myfile.dat","rb")

(D) print(obj)

Answer options

Q13:

2026: 21 May Shift 1

File Handling

Easy

Computer Science

_________method reads all the lines and returns the lines along with newline character, as a list of strings.

Answer options

Q14:

2026: 21 May Shift 1

File Handling

Medium

Computer Science

The seek() method can be used to position the file object at a particular position in a file depending upon the offset. What will be the offset position, if someone wants to write at the current position of the file?

Answer options

Q15:

2026: 20 May Shift 1

File Handling

Easy

Computer Science

____________ is a process of transforming data or object in memory to a stream of bytes.

Answer options

Q16:

2026: 20 May Shift 1

File Handling

Medium

Computer Science

What will be the output after execution of the following commands on a file, consider 'f' as the file pointer?

f.seek(10)

f.read(1)

f.read(1)

f.tell()

Answer options

Q17:

2026: 19 May Shift 1

File Handling

Easy

Computer Science

Arrange the following statement in order to add the content to a text file.

(A) Write the file content using write() method

(B) Open the file in append mode

(C) Take the input from the user

(D) Close the file

Answer options

Q18:

2026: 19 May Shift 1

File Handling

Easy

Computer Science

Which function returns an integer that specifies the current position of the file object in the file?

Answer options

Q19:

2026: 18 May Shift 2

File Handling

Easy

Computer Science

Consider 'fileobj' as the file object. The method fileobj.seek(5, 0) will position the file object at:

Answer options

Q20:

2026: 18 May Shift 2

File Handling

Easy

Computer Science

Arrange the following program statements in correct sequence in order to read the contents from a binary file:

A. var = pickle.load(fileobj)

B. fileobj = open("mybinary.dat", "rb")

C. print(var)

D. import pickle

Answer options

Q21:

2026: 13 May Shift 2

File Handling

Easy

Computer Science

Which of the following is the correct Python statement to open a text file “example.txt” in both read and write mode?

Answer options

Q22:

2026: 13 May Shift 2

File Handling

Medium

Computer Science

Match List-I with List-II

List-IList-II
(A) Serialization(I) load()
(B) De-Serialization(II) tell()
(C) Specifies the current position of the file object(III) dump()
(D) Position the file object at a particular position(IV) seek()
Answer options

Q23:

2026: 11 May Shift 2

File Handling

Easy

Computer Science

Which function is used to write in a file without over writing the previous content?

Answer options

Q24:

2025: 3 June Shift 2

File Handling

Medium

Computer Science

Match List-I with List-II

List-IList-II
(A) tell()(I) used to position the file object at a particular position
(B) seek()(II) used for pickling python object to a binary file
(C) load()(III) returns an integer which specifies the current position of the file object in the file
(D) dump()(IV) used for unpicking data from a binary file
Answer options

Q25:

2025: 3 June Shift 2

File Handling

Easy

Computer Science

__________files are also stored in terms of bytes, but unlike text files , these bytes do not represent the ASCII value of characters.

Answer options

Q26:

2025: 30 May Shift 2

File Handling

Easy

Computer Science

While working with text files, each line of a text file is terminated by a special character, called ________

Answer options

Q27:

2025: 30 May Shift 2

File Handling

Easy

Computer Science

Identify the concept being associated with given characteristics:

a) Data stored in terms of bytes (0s and 1s)

b) Not human readable

c) No translation of data required

d) Faster in execution

Answer options

Q28:

2025: 30 May Shift 2

File Handling

Easy

Computer Science

Identify the correct program code to open the text file in write mode only.

Note:(If the file already exists, all the contents will be overwritten. If the file doesn’t exist, then a new file will be created.)

Answer options

Q29:

2025: 27 May Shift 2

File Handling

Easy

Computer Science

Which of the following functions do you use to write data in binary format?

Answer options

Q30:

2025: 27 May Shift 2

File Handling

Medium

Computer Science

What will be the output of the following program?

f=open("comp.txt","r")

for line in f:

words=line.split()

for i in words:

for letter in i :

if(letter.isdigit()):

print(letter)

Answer options