Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Loading Images in Pygame

Total questions: 20

Worksheet time: 10mins

Name
Class
Date
1.

Which Pygame function loads an external image file into a Surface object?

a)

pygame.image.save('path')

b)

pygame.display.set_mode()

c)

pygame.Surface.convert()

d)

pygame.image.load('path')

2.

You store sprite.png in the same folder as main.py and want a Surface from it. Which line correctly creates the Surface?

a)

sprite = pygame.Surface('sprite.png')

b)

sprite = pygame.image.load('sprite.png')

c)

sprite = pygame.display.load('sprite.png')

d)

sprite = pygame.image.open('sprite.png')

3.

When the image file is not in the script directory, how should you reference it to load correctly?

a)

Rename the file to default.png

b)

Call load without any path

c)

Use the full absolute path string

d)

Create an empty Surface instead

4.

Which method returns both width and height of a Pygame Surface in one call?

a)

get_rect returning a list

b)

get_size returning a tuple

c)

get_rect with size attribute

d)

get_width with get_height together

5.

You have surface.get_rect(). Which indices correspond to width and height respectively?

a)

[0] width, [1] height

b)

[1] width, [2] height

c)

[2] width, [3] height

d)

[3] width, [4] height

6.

To read dimensions separately without a tuple, which pair of methods should you call?

a)

get_size and slice methods

b)

get_width and get_height methods

c)

get_size and convert methods

d)

get_rect and center methods

7.

Which function rotates a Pygame surface counterclockwise by a given angle in degrees?

a)

pygame.transform.roll(img, angle)

b)

pygame.transform.scale(img, (w, h))

c)

pygame.transform.rotate(img, angle)

d)

pygame.transform.flip(img, flip_x, flip_y)

8.

When using pygame.transform.flip(img, flip_x, flip_y), what does flip_x control?

a)

Horizontal mirroring of the surface

b)

Vertical mirroring of the surface

c)

Counterclockwise rotation in degrees

d)

Uniform scaling on both axes

9.

Which parameter pair must be provided to pygame.transform.scale to set the new size?

a)

Two booleans for axes

b)

A single integer size

c)

A float scale factor

d)

A tuple (width, height)

10.

An image needs to be turned upside down. Which call achieves this directly?

a)

pygame.transform.flip(img, False, True)

b)

pygame.transform.rotate(img, 45)

c)

pygame.transform.scale(img, (200, 200))

d)

pygame.transform.flip(img, True, False)

11.

You must rotate a sprite so its top points east. The sprite’s current top points north. What angle should you use?

a)

Rotate by 270 degrees

b)

Rotate by 90 degrees

c)

Rotate by 180 degrees

d)

Rotate by 45 degrees

12.

A logo looks stretched after scaling. Which mistake most likely caused this?

a)

Using unequal width and height values

b)

Using flip_x set to True

c)

Rotating by a non-right angle

d)

Passing the image without a tuple

13.

Which function call correctly saves a Pygame Surface to an image file?

a)

pygame.image.save(surf, "output.png")

b)

pygame.save.image("output.png", surf)

c)

pygame.surface.save("output.png", surf)

d)

pygame.image.write(surf, "output.png")

14.

You need lossless export of a Surface with transparency. Which filename extension should you use?

a)

TGA using default settings

b)

BMP without transparency

c)

JPEG with compression

d)

PNG with alpha channel

15.

In a Python image viewer, which key event is most appropriate to rotate the image exactly 90 degrees clockwise?

a)

R key press event handler

b)

Arrow Left key press event

c)

Mouse wheel scroll up event

d)

Space bar toggle event

16.

You need smooth zoom in/out using the mouse wheel while keeping the car centered in view. Which approach best maintains the focus during zoom?

a)

Crop before any scaling action

b)

Scale from image origin top-left

c)

Scale around current mouse position

d)

Translate after scaling by window size

17.

Which code change correctly moves an image upward in a Pygame loop when the up arrow is held?

a)

x -= speed each frame pressed

b)

x += speed each frame pressed

c)

y += speed each frame pressed

d)

y -= speed each frame pressed

18.

You need a Pygame program where clicking a bomb sprite swaps it with a boom image. Which approach best ensures only the clicked sprite changes?

a)

Use rect collision on mouse position per sprite

b)

Switch all images on any mouse click anywhere

c)

Rotate the image by a small angle on click

d)

Check global click flag then redraw every sprite

19.

In a Pygame image viewer, which user action most appropriately controls zoom level to inspect details without altering the image pixels?

a)

Dragging a rectangle selection slowly

b)

Pressing the spacebar continuously

c)

Scrolling the mouse wheel up or down

d)

Right-clicking the image repeatedly

20.

You are building a Pygame tool to crop a photo. What is the most effective interaction pattern to let users choose the exact area to keep?

a)

Type coordinates into a text field

b)

Drag a rectangle over the desired region

c)

Double-click anywhere to auto-crop

d)

Use the mouse wheel to adjust crop