WorksheetsLoading Images in Pygame
Total questions: 20
Worksheet time: 10mins
Which Pygame function loads an external image file into a Surface object?
pygame.image.save('path')
pygame.display.set_mode()
pygame.Surface.convert()
pygame.image.load('path')
You store sprite.png in the same folder as main.py and want a Surface from it. Which line correctly creates the Surface?
sprite = pygame.Surface('sprite.png')
sprite = pygame.image.load('sprite.png')
sprite = pygame.display.load('sprite.png')
sprite = pygame.image.open('sprite.png')
When the image file is not in the script directory, how should you reference it to load correctly?
Rename the file to default.png
Call load without any path
Use the full absolute path string
Create an empty Surface instead
Which method returns both width and height of a Pygame Surface in one call?
get_rect returning a list
get_size returning a tuple
get_rect with size attribute
get_width with get_height together
You have surface.get_rect(). Which indices correspond to width and height respectively?
[0] width, [1] height
[1] width, [2] height
[2] width, [3] height
[3] width, [4] height
To read dimensions separately without a tuple, which pair of methods should you call?
get_size and slice methods
get_width and get_height methods
get_size and convert methods
get_rect and center methods
Which function rotates a Pygame surface counterclockwise by a given angle in degrees?
pygame.transform.roll(img, angle)
pygame.transform.scale(img, (w, h))
pygame.transform.rotate(img, angle)
pygame.transform.flip(img, flip_x, flip_y)
When using pygame.transform.flip(img, flip_x, flip_y), what does flip_x control?
Horizontal mirroring of the surface
Vertical mirroring of the surface
Counterclockwise rotation in degrees
Uniform scaling on both axes
Which parameter pair must be provided to pygame.transform.scale to set the new size?
Two booleans for axes
A single integer size
A float scale factor
A tuple (width, height)
An image needs to be turned upside down. Which call achieves this directly?
pygame.transform.flip(img, False, True)
pygame.transform.rotate(img, 45)
pygame.transform.scale(img, (200, 200))
pygame.transform.flip(img, True, False)
You must rotate a sprite so its top points east. The sprite’s current top points north. What angle should you use?
Rotate by 270 degrees
Rotate by 90 degrees
Rotate by 180 degrees
Rotate by 45 degrees
A logo looks stretched after scaling. Which mistake most likely caused this?
Using unequal width and height values
Using flip_x set to True
Rotating by a non-right angle
Passing the image without a tuple
Which function call correctly saves a Pygame Surface to an image file?
pygame.image.save(surf, "output.png")
pygame.save.image("output.png", surf)
pygame.surface.save("output.png", surf)
pygame.image.write(surf, "output.png")
You need lossless export of a Surface with transparency. Which filename extension should you use?
TGA using default settings
BMP without transparency
JPEG with compression
PNG with alpha channel
In a Python image viewer, which key event is most appropriate to rotate the image exactly 90 degrees clockwise?
R key press event handler
Arrow Left key press event
Mouse wheel scroll up event
Space bar toggle event
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?
Crop before any scaling action
Scale from image origin top-left
Scale around current mouse position
Translate after scaling by window size
Which code change correctly moves an image upward in a Pygame loop when the up arrow is held?
x -= speed each frame pressed
x += speed each frame pressed
y += speed each frame pressed
y -= speed each frame pressed
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?
Use rect collision on mouse position per sprite
Switch all images on any mouse click anywhere
Rotate the image by a small angle on click
Check global click flag then redraw every sprite
In a Pygame image viewer, which user action most appropriately controls zoom level to inspect details without altering the image pixels?
Dragging a rectangle selection slowly
Pressing the spacebar continuously
Scrolling the mouse wheel up or down
Right-clicking the image repeatedly
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?
Type coordinates into a text field
Drag a rectangle over the desired region
Double-click anywhere to auto-crop
Use the mouse wheel to adjust crop
