0
0
Raspberry Piprogramming~10 mins

PWMLED for brightness in Raspberry Pi - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to import the PWMLED class from gpiozero.

Raspberry Pi
from gpiozero import [1]
Drag options to blanks, or click blank then click option'
ALED
BPWMLED
CButton
DOutputDevice
Attempts:
3 left
💡 Hint
Common Mistakes
Importing LED instead of PWMLED
Importing Button which is unrelated
Importing OutputDevice which is too general
2fill in blank
medium

Complete the code to create a PWMLED object on GPIO pin 17.

Raspberry Pi
led = PWMLED([1])
Drag options to blanks, or click blank then click option'
A18
B27
C22
D17
Attempts:
3 left
💡 Hint
Common Mistakes
Using pin 18 or 22 which are valid pins but not the one asked
Using pin 27 which is higher than 22
3fill in blank
hard

Fix the error in setting the LED brightness to 50%.

Raspberry Pi
led.value = [1]
Drag options to blanks, or click blank then click option'
A0.5
B50
C1
D5
Attempts:
3 left
💡 Hint
Common Mistakes
Using 50 which is out of range
Using 5 which is too high
Using 1 which is full brightness
4fill in blank
hard

Fill both blanks to create a dictionary of LED brightness for words longer than 3 letters.

Raspberry Pi
brightness = {word: [1] for word in words if len(word) [2] 3}
Drag options to blanks, or click blank then click option'
Alen(word)
B>
C<
D==
Attempts:
3 left
💡 Hint
Common Mistakes
Using '<' or '==' which filter wrong words
Using word instead of len(word) for brightness
5fill in blank
hard

Fill all three blanks to create a dictionary mapping uppercase words to brightness values greater than 0.3.

Raspberry Pi
brightness = [1]: [2] for word in words if [2] [3] 0.3}
Drag options to blanks, or click blank then click option'
Aword.upper()
Bword
C>
Dlen(word)
Attempts:
3 left
💡 Hint
Common Mistakes
Using word as the value instead of len(word)
Using '<' instead of '>' in filter
Using word instead of word.upper() as key