File Handling Quiz-16

Share with others

Welcome to your File Handling Quiz-16

School Name
Q151. Aman wants to read the first 21 characters from file "sports.txt". Help him to find the correct code from the options given below:

fh=open("story.txt", 'r')

Q152. Anshuman wants to move/change the current position of file handle 'fn' to 15 bytes forward. As a friend of Anshuman, help him to find the correct code given below:

Q153. Arman is learning file handling in class 12. He wants to open the binary file in append mode. Help him to choose the correct mode given below.

Q154. Sahil is trying to open a text file. He is confused about the module to be imported for working in text file. As a friend of Sahil, help him to remove his confusion and choose the correct option.

Q155. Consider the following code and identify the data type of variable "d"

Fn = open("Myfile.txt")
d =

Q156. What is represented by 0 in the statement :, 0)

Q157. Write the output of the following:

fn = open("mystery.txt", 'r')

Q158. Sarika is trying to write a list L1 = [12, 34, 54, 32] in a binary file named "listing.dat". Which of the following statement will help her to write?

Q159. Aman is working in a text file named "weight.txt". He has written the following code. Choose the final content of the file after execution of the code.

Consider the following content is written in a file:

First reduce the weight of your plate

w1=open("weight.txt", "w") 
w1.write(“for weight loss”)
w1.close( )

Q160. Write the output of the following code:

Consider the following content is written in file : "weight.txt"

Weight Loss
Less Food
Less Carbohydrate
More Protein

Code given below: 

fn = open("story.txt")
lc = 0
dc = fn.readlines()
for ln in dc:
      if ln[-3] in 'to':
            lc += 1

Share with others

Leave a Reply

error: Content is protected !!