Bird
0
0

What will be displayed on the OLED after running this code snippet?

medium📝 Predict Output Q4 of 15
Raspberry Pi - Display and Output
What will be displayed on the OLED after running this code snippet?
from PIL import Image, ImageDraw, ImageFont
from luma.core.interface.serial import i2c
from luma.oled.device import ssd1306

serial = i2c(port=1, address=0x3C)
device = ssd1306(serial)

image = Image.new('1', (device.width, device.height))
draw = ImageDraw.Draw(image)
draw.text((10, 10), 'Hi', fill=255)
device.display(image)
AThe OLED screen remains blank
BThe text 'Hi' appears near the top-left corner of the OLED screen
CAn error occurs because font is not specified
DThe text 'Hi' appears centered on the OLED screen
Step-by-Step Solution
Solution:
  1. Step 1: Analyze text drawing coordinates

    The text is drawn at position (10, 10), which is near the top-left corner of the screen.
  2. Step 2: Check font usage and display call

    Default font is used if none specified, so no error occurs. The image is sent to the device display.
  3. Final Answer:

    The text 'Hi' appears near the top-left corner of the OLED screen -> Option B
  4. Quick Check:

    Text position = (10,10) near top-left [OK]
Quick Trick: Text coordinates control position on OLED [OK]
Common Mistakes:
MISTAKES
  • Assuming missing font causes error
  • Thinking text auto-centers without code
  • Expecting blank screen without drawing

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Raspberry Pi Quizzes