Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

File Handling in Python Quiz

Total questions: 10

Worksheet time: 5mins

Name
Class
Date
1.

What is the need for data files in Python?

a)

To store data in RAM

b)

To permanently store data for future use

c)

To erase data when the program is over

d)

To handle small amount of data

2.

Which type of file stores data in binary format?

a)

JSON file

b)

CSV file

c)

Text file

d)

Binary file

3.

What is the file extension for CSV files?

a)

.data

b)

.txt

c)

.csv

d)

.bin

4.

Which method is used to open a file in Python?

a)

append()

b)

write()

c)

read()

d)

open()

5.

What is the default mode when opening a file in Python?

a)

Binary

b)

Append

c)

Write

d)

Read

6.

Which method is used to write a sequence of strings to a file in Python?

a)

readlines()

b)

read()

c)

writelines()

d)

write()

7.

What is the method used to read a specific number of bytes from a file in Python?

a)

read(n)

b)

readlines()

c)

readline()

d)

readall()

8.

What is the standard input stream in Python?

a)

stdout

b)

input()

c)

stdin

d)

stderr

9.

How can standard output be redirected to a file in Python?

a)

Reassigning sys.stdout

b)

sys.stdout.writelines()

c)

print('data', file=fileobject)

d)

sys.stdout.write()

10.

What is the method used to reassign the standard input stream in Python?

a)

sys.stdin.write()

b)

Reassigning sys.stdin

c)

input()

d)

sys.stdin.readline()