Bird
0
0

What will this code print?

medium📝 Predict Output Q5 of 15
Raspberry Pi - gpiozero Library
What will this code print?
from gpiozero import PWMLED
led = PWMLED(13)
led.value = 1.2
print(led.value)
A1.2
B1.0
C0.0
DValueError at assignment
Step-by-Step Solution
Solution:
  1. Step 1: Understand PWMLED value limits

    Brightness values above 1.0 are capped at 1.0 internally.
  2. Step 2: Check printed value

    Assigning 1.2 sets brightness to max 1.0; printing led.value outputs 1.0.
  3. Final Answer:

    1.0 -> Option B
  4. Quick Check:

    Brightness capped at 1.0 = D [OK]
Quick Trick: Brightness above 1.0 caps to 1.0 automatically [OK]
Common Mistakes:
  • Expecting error on out-of-range value
  • Assuming value stays 1.2
  • Confusing with 0.0 default

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Raspberry Pi Quizzes