wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

FILE HANDLING IN PYTHON

Total questions: 10

Worksheet time: 8mins

Name
Class
Date
1.



(a)  

2.

Mode in the following program to open file for writing in a mode where new data will be added at the end of old data


file =open("poem.txt","__")

a)

r

b)

a

c)

w

d)

x

3.

see the program and fill in the blank with correct statement.

(a)  

4.

Choose the correct statement to close a file stream named myfile:

a)

myfile.terminate()

b)

myfile.end()

c)

myfile.close()

d)

myfile.remove()

5.

See the following code snippet and fill in the blank with appropriate statement

(a)  

6.

Fill in the blank with appropriate statement.

(a)  

7.

which function is used to read records from a binary file?

a)

pickle.load(f)

b)

pickle.read()

c)

pickle.open()

d)

pickle.dump(l,f)

8.

write statement to use the required module for working with comma separated values (csv) files.

(a)  

9.

Write the appropriate statement in the blank.

(a)  

10.

Which statement(s) is/are true to open a binary file "Record.dat" for reading and writing.

a)

file =open("Record.dat","wb")

b)

file =open("Record.dat","rb")

c)

file =open("Record.dat","ab")

d)

file =open("Record.dat","rb+")