wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

File Handling

Total questions: 10

Worksheet time: 5mins

Name
Class
Date
1.

What is the first file handling operation mentioned in the text?

a)

open

b)

write

c)

close

d)

read

2.

What does the 'R' parameter signify when opening a file in Python?

a)

Read mode

b)

Binary mode

c)

Write mode

d)

Append mode

3.

What is used to remove the newline character when reading from a file?

a)

.strip()

b)

.delete()

c)

.remove()

d)

.cut()

4.

What does setting a Boolean variable to false indicate in file handling?

a)

File is empty

b)

End of the file is reached

c)

File is corrupted

d)

End of the file is not reached

5.

What parameter is used to append to a file in Python?

a)

A

b)

R

c)

W

d)

B

6.

What is the correct order of operations for writing data to a file?

a)

Write, open, close

b)

Close, open, write

c)

Open, close, write

d)

Open, write, close

7.

What does the '.write' method do?

a)

Deletes data from a file

b)

Opens a file for writing

c)

Reads data from a file

d)

Writes data to a file

8.

What is data dependency?

a)

A type of data error

b)

A method to write data

c)

A requirement for data to be in a specific order

d)

A Python library for file handling

9.

What does the 'A' parameter do when opening a file?

a)

Opens the file in read-only mode

b)

Clears the file before writing

c)

Appends to the end of the file

d)

Creates a new file

10.

What is the purpose of the 'close' operation in file handling?

a)

To free up resources

b)

To rename the file

c)

To save changes to the file

d)

To delete the file