File Handling Py Reading

File Handling Py Reading

Assessment

Passage

Computers

11th - 12th Grade

Hard

Created by

Andrew Ward

FREE Resource

6 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What function is used to open a file in Python?

open()

read()

write()

close()

2.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Which mode is used to open a file for writing, creating a new file or overwriting an existing one?

w

r

a

r+

3.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What does the read() function do in Python file handling?

Reads the entire file

Reads one line from the file

Writes data to the file

Closes the file

4.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Which function is used to write a list of lines to a file in Python?

writelines()

write()

readlines()

read()

5.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the purpose of the close() function in file handling?

To save resources by closing the file

To open a file

To read the file's contents

To write to a file

6.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

In which mode can you both read and write to a file in Python?

r+

r

w

a