Q1:
2026: 31 May Shift 1
Computer Science
File Handling
Easy
Computer Science
The process of converting a python object for writing into a binary file is called____.
2026: 31 May Shift 1
Computer Science
File Handling
Easy
Computer Science
The process of converting a python object for writing into a binary file is called____.
2026: 31 May Shift 1
Computer Science
File Handling
Easy
Computer Science
Match the LIST-I with LIST-II
| LIST-I | LIST-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 |
2026: 29 May Shift 2
Computer Science
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()
2026: 29 May Shift 1
Computer Science
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]
2026: 29 May Shift 1
Computer Science
File Handling
Medium
Computer Science
Match List-I with List-II
| List-I - Command | List-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. |
2026: 26 May Shift 1
Computer Science
File Handling
Easy
Computer Science
The statement fileobject.seek(10,0) will __________.
2026: 24 May Shift 1
Computer Science
File Handling
Easy
Computer Science
Which of the following methods is used to position a file object to a specific position in a file?
2026: 24 May Shift 1
Computer Science
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')
2026: 23 May Shift 2
Computer Science
File Handling
Easy
Computer Science
When the byte stream is converted back to Python object, it is known as _______________.
2026: 23 May Shift 1
Computer Science
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)
2026: 23 May Shift 1
Computer Science
File Handling
Easy
Computer Science
How do you move the file pointer to the byte from the beginning of a file in Python?
2026: 21 May Shift 1
Computer Science
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)
2026: 21 May Shift 1
Computer Science
File Handling
Easy
Computer Science
_________method reads all the lines and returns the lines along with newline character, as a list of strings.
2026: 21 May Shift 1
Computer Science
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?
2026: 20 May Shift 1
Computer Science
File Handling
Easy
Computer Science
____________ is a process of transforming data or object in memory to a stream of bytes.
2026: 20 May Shift 1
Computer Science
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()
2026: 19 May Shift 1
Computer Science
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
2026: 19 May Shift 1
Computer Science
File Handling
Easy
Computer Science
Which function returns an integer that specifies the current position of the file object in the file?
2026: 18 May Shift 2
Computer Science
File Handling
Easy
Computer Science
Consider 'fileobj' as the file object. The method fileobj.seek(5, 0) will position the file object at:
2026: 18 May Shift 2
Computer Science
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
2026: 13 May Shift 2
Computer Science
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?
2026: 13 May Shift 2
Computer Science
File Handling
Medium
Computer Science
Match List-I with List-II
| List-I | List-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() |
2026: 11 May Shift 2
Computer Science
File Handling
Easy
Computer Science
Which function is used to write in a file without over writing the previous content?
2025: 3 June Shift 2
Computer Science
File Handling
Medium
Computer Science
Match List-I with List-II
| List-I | List-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 |
2025: 3 June Shift 2
Computer Science
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.
2025: 30 May Shift 2
Computer Science
File Handling
Easy
Computer Science
While working with text files, each line of a text file is terminated by a special character, called ________
2025: 30 May Shift 2
Computer Science
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
2025: 30 May Shift 2
Computer Science
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.)
2025: 27 May Shift 2
Computer Science
File Handling
Easy
Computer Science
Which of the following functions do you use to write data in binary format?
2025: 27 May Shift 2
Computer Science
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)