Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to print the name of the device.
Raspberry Pi
device_name = "[1]" print(device_name)
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Choosing other small computers like Arduino or Microbit.
✗ Incorrect
The Raspberry Pi is a small, affordable computer used for learning programming and electronics.
2fill in blank
mediumComplete the code to turn on an LED connected to GPIO pin 17.
Raspberry Pi
import RPi.GPIO as GPIO GPIO.setmode(GPIO.BCM) GPIO.setup(17, GPIO.OUT) GPIO.output(17, [1])
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using GPIO.LOW which turns the LED off.
✗ Incorrect
GPIO.HIGH turns the LED on by sending voltage to the pin.
3fill in blank
hardFix the error in the code to read a button press on GPIO pin 18.
Raspberry Pi
import RPi.GPIO as GPIO GPIO.setmode(GPIO.BCM) GPIO.setup(18, [1]) if GPIO.input(18): print("Button pressed")
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Setting the pin as output instead of input.
✗ Incorrect
GPIO.IN sets the pin as input to read button presses.
4fill in blank
hardFill both blanks to create a dictionary of GPIO pin states for pins 22 and 23.
Raspberry Pi
pin_states = {22: GPIO.[1], 23: GPIO.[2] Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using IN or OUT which are pin modes, not states.
✗ Incorrect
GPIO.HIGH and GPIO.LOW represent the on/off states of pins.
5fill in blank
hardFill all three blanks to set up GPIO, turn on pin 24, and clean up.
Raspberry Pi
import RPi.GPIO as GPIO GPIO.setmode(GPIO.[1]) GPIO.setup(24, GPIO.[2]) GPIO.output(24, GPIO.[3]) GPIO.cleanup()
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using IN instead of OUT for setup or LOW instead of HIGH for output.
✗ Incorrect
BCM sets pin numbering, OUT sets pin as output, HIGH turns pin on.