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

Q1:

2025: 27 May Shift 2

File Handling

Easy

Computer Science

Which of the following command is used to open file "c:\comp.txt" for writing in binary format only?

Answer options
Option 4
Correct Answer
Explanation for 2025: 27 May Shift 2 CSE question 1

Q2:

2025: 22 May Shift 1

File Handling

Easy

Computer Science

Match List-I with List-II

List-IList-II
(A) read()(I) writes the list of strings to the file
(B) write()(II) reads the specified number of characters from the file
(C) writelines()(III) writes the string to the file
(D) readlines()(IV) reads the file line by line into a list
Answer options
Option 3
Correct Answer
Explanation for 2025: 22 May Shift 1 CSE question 2

Q3:

2025: 22 May Shift 1

File Handling

Easy

Computer Science

Sequence the steps to write data to a file and then read it back:

(A). Write data to the file.

(B). Open the file in w+ mode.

(C). Read the data from the file.

(D). Seek to the beginning of file.

Answer options
Option 4
Correct Answer
Explanation for 2025: 22 May Shift 1 CSE question 3

Q4:

2025: 22 May Shift 1

File Handling

Easy

Computer Science

Which of the following is the correct method to write into a text file.

Answer options
Option 1
Correct Answer
Explanation for 2025: 22 May Shift 1 CSE question 4

Q5:

2025: 22 May Shift 1

File Handling

Easy

Computer Science

The pickle module is used for _______________and ________ any python object structure.

Answer options
Option 2
Correct Answer
Explanation for 2025: 22 May Shift 1 CSE question 5

Q6:

2025: 21 May Shift 1

File Handling

Easy

Computer Science

dump( ) method is used for _______________.

Answer options
Option 1
Correct Answer
Explanation for 2025: 21 May Shift 1 CSE question 6

Q7:

2025: 20 May Shift 1

File Handling

Easy

Computer Science

Given data in text file "rhymes.txt" as follows:

Johny Johny Yes Papa

Eating Sugar No Papa

Telling a lie No Papa

Open your mouth Ha Ha Ha

Find the output for the following code:

my1=open("rhymes.txt","r")

data=my1.read(10)

print(data)

my1.close()

Answer options
Option 3
Correct Answer
Explanation for 2025: 20 May Shift 1 CSE question 7

Q8:

2025: 20 May Shift 1

File Handling

Easy

Computer Science

Identify the correct code to open a file "file1.txt", but not required to close the file using close() statement:

Answer options
Option 4
Correct Answer
Explanation for 2025: 20 May Shift 1 CSE question 8

Q9:

2025: 16 May Shift 1

File Handling

Easy

Computer Science

Arrange the following lines of code for writing into a file in the correct order:

(A) lines = ["Hello Everyone\n", "Writing in multiple lines"];

(B) myobj.writelines(lines)

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

(D) myobj.close()

Answer options
Option 2
Correct Answer
Explanation for 2025: 16 May Shift 1 CSE question 9

Q10:

2025: 16 May Shift 1

File Handling

Easy

Computer Science

_____method is used to position the file object at a particular position in a file.

Answer options

Q11:

2025: 15 May Shift 2

File Handling

Easy

Computer Science

Identify the correct meaning of the code statement:

file.seek(10)

Answer options

Q12:

2025: 15 May Shift 2

File Handling

Easy

Computer Science

Identify the correct sequence of working in binary files:

(A) f=open("myfile.dat","rb")

(B) f.close()

(C) import pickle

(D) data=pickle.load(f)

Answer options

Q14:

2025: 14 May Shift 1

File Handling

Easy

Computer Science

Which of the following methods is used to unpickling data from a binary file?

Answer options

Q15:

2025: 14 May Shift 1

File Handling

Easy

Computer Science

What is the default file offset position when we open a file in append mode?

Answer options

Q16:

2025: 13 May Shift 2

File Handling

Easy

Computer Science

Identify the correct python statement to open a text file "data.txt" in both read and write mode.

Answer options