Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Python libraries: Random, PIL, Wave

Total questions: 14

Worksheet time: 7mins

Name
Class
Date
1.

What does the function random() return?

a)

A random float number between 0 and 1

b)

A random element from a list

c)

A list of unique elements

d)

A random integer between 0 and 10

2.

Which function would you use to select a random item from a list?

a)

randint(a, b)

b)

sample(population, k)

c)

shuffle(x)

d)

choice(seq)

3.

What is the RGB code for the color Green?

a)

(255, 255, 0)

b)

(0, 0, 255)

c)

(0, 255, 0)

d)

(255, 0, 0)

4.

Which method is used to create a new image in PIL?

a)

Image.open()

b)

Image.save()

c)

Image.create()

d)

Image.new()

5.

What does the function wave.open() do?

a)

Writes frames to a WAV file

b)

Reads frames from a WAV file

c)

Creates a new WAV file

d)

Opens a WAV file

6.

Which function would you use to shuffle a list in Python?

a)

randomize(x)

b)

shuffle(x)

c)

sort(x)

d)

mix(x)

7.

What is the purpose of the ImageDraw module in PIL?

a)

To manipulate image colors

b)

To open image files

c)

To draw on images

d)

To save images

8.

Which function is used to resize an image in PIL?

a)

Image.resize()

b)

Image.change_size()

c)

Image.scale()

d)

Image.size()

9.

What does the function sample(population, k) return?

a)

A shuffled list

b)

A random integer

c)

A list of k unique elements from the population

d)

A random float

10.

Which of the following is NOT a standard color in RGB?

a)

Red

b)

Purple

c)

Green

d)

Blue

11.

What does the method getparams() return in the wave module?

a)

The audio duration

b)

The file path

c)

The number of frames

d)

Audio file parameters

12.

Which function is used to apply a filter to an image in PIL?

a)

Image.apply_filter()

b)

Image.use_filter()

c)

Image.add_filter()

d)

Image.filter()

13.

What is the purpose of the function readframes(n) in the wave module?

a)

To get audio parameters

b)

To open a WAV file

c)

To read n frames from the file

d)

To write frames to a WAV file

14.

Which function would you use to save an image in PIL?

a)

Image.save()

b)

Image.write()

c)

Image.export()

d)

Image.store()