0
0
Raspberry Piprogramming~10 mins

What is Raspberry Pi - Interactive Quiz & Practice

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

Complete 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'
ARaspberry Pi
BArduino
CMicrobit
DBeagleBone
Attempts:
3 left
💡 Hint
Common Mistakes
Choosing other small computers like Arduino or Microbit.
2fill in blank
medium

Complete 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'
AGPIO.PWM
BGPIO.LOW
CGPIO.IN
DGPIO.HIGH
Attempts:
3 left
💡 Hint
Common Mistakes
Using GPIO.LOW which turns the LED off.
3fill in blank
hard

Fix 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'
AGPIO.OUT
BGPIO.HIGH
CGPIO.IN
DGPIO.LOW
Attempts:
3 left
💡 Hint
Common Mistakes
Setting the pin as output instead of input.
4fill in blank
hard

Fill 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'
AHIGH
BLOW
CIN
DOUT
Attempts:
3 left
💡 Hint
Common Mistakes
Using IN or OUT which are pin modes, not states.
5fill in blank
hard

Fill 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'
ABCM
BOUT
CHIGH
DIN
Attempts:
3 left
💡 Hint
Common Mistakes
Using IN instead of OUT for setup or LOW instead of HIGH for output.