Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Python Image Library

Total questions: 10

Worksheet time: 5mins

Name
Class
Date
1.

What does the Image.new() function in PIL do?

a)

Create a new Python image file.

b)

Create a new empty image with a specified mode and size.

c)

Load an existing image file

d)

Crop an image to a specified size

2.

Which Python library is commonly used for image manipulation and drawing operations?

a)

PIL (Python Image Library)

b)

NumPy

c)

OpenCV

d)

Matplotlib

3.

What does the ImageDraw module in PIL allow you to do?

a)

Resize an image

b)

Create a new image

c)

Draw shapes and text on an image

d)

Convert images to different formats

4.

Which function is used to draw an ellipse on an image using PIL?

a)

ImageDraw.draw_circle()

b)

ImageDraw.draw_ellipse()

c)

Image.draw_ellipse()

d)

Image.ellipse()

5.

What does the ImageDraw.rectangle() method in PIL do?

a)

Crop the image to a specified rectangle

b)

Draw a filled rectangle on an image

c)

Rotate the image by a specified angle

d)

Resize the image to a rectangle shape

6.

Which function is used to draw a polygon on an image using PIL?

a)

ImageDraw.draw_polygon()

b)

ImageDraw.draw_shape()

c)

Image.draw_polygon()

d)

Image.polygon()

7.

What parameter is required when creating a new image using Image.new()?

a)

Image mode (e.g., 'RGB', 'RGBA')

b)

Image filename

c)

Image size in pixels

d)

Image DPI (Dots Per Inch)

8.

How do you specify the color of the shapes you draw with PIL's ImageDraw module?

a)

By setting the color attribute of the image

b)

By specifying the color when creating the image

c)

By using the fill parameter in drawing methods

d)

By calling the setColor() method on the image

9.

What is the purpose of the outline parameter in the ImageDraw.rectangle() method in PIL?

a)

It sets the background color of the rectangle.

b)

It specifies the width of the rectangle's border.

c)

It sets the color of the rectangle's border.

d)

It determines the shape of the rectangle.

10.

How can you draw a filled polygon with a transparent background using PIL?

a)

Set the polygon's color to be transparent using the ImageDraw.set_alpha() method.

b)

Use the 'RGBA' mode when creating the image and specify the polygon's color with an alpha value less than 255.

c)

There is no way to create a filled polygon with a transparent background in PIL.

d)

Set the background parameter of the ImageDraw.polygon() method to 'transparent'.