0
0
Raspberry Piprogramming~10 mins

Python on 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 print a message on the Raspberry Pi console.

Raspberry Pi
print([1])
Drag options to blanks, or click blank then click option'
A"Hello, Raspberry Pi!"
BHello, Raspberry Pi!
Cecho "Hello, Raspberry Pi!"
Dprint("Hello, Raspberry Pi!")
Attempts:
3 left
💡 Hint
Common Mistakes
Forgetting to put quotes around the message.
Using shell commands like echo inside print.
2fill in blank
medium

Complete the code to read input from the user on Raspberry Pi.

Raspberry Pi
user_name = [1]("Enter your name: ")
Drag options to blanks, or click blank then click option'
Ainput
Bprint
Cread
Dscan
Attempts:
3 left
💡 Hint
Common Mistakes
Using print instead of input.
Using functions not available in Python.
3fill in blank
hard

Fix the error in the code to blink an LED connected to GPIO pin 17.

Raspberry Pi
import RPi.GPIO as GPIO
import time

GPIO.setmode(GPIO.BCM)
GPIO.setup(17, GPIO.OUT)

GPIO.output(17, [1])
time.sleep(1)
GPIO.output(17, GPIO.LOW)
Drag options to blanks, or click blank then click option'
AON
BGPIO.HIGH
CTrue
D1
Attempts:
3 left
💡 Hint
Common Mistakes
Using boolean True instead of GPIO.HIGH.
Using numeric 1 instead of GPIO.HIGH.
4fill in blank
hard

Fill both blanks to create a dictionary of sensor readings where keys are sensor names and values are readings above 50.

Raspberry Pi
sensor_data = { [1]: [2] for [1] in sensors if sensors[[1]] > 50 }
Drag options to blanks, or click blank then click option'
Asensor
Breading
Csensors[sensor]
Dsensor_data
Attempts:
3 left
💡 Hint
Common Mistakes
Using different variable names for key and value.
Using the dictionary name as key or value.
5fill in blank
hard

Fill all three blanks to create a dictionary of uppercase sensor names mapped to their readings if readings are above 30.

Raspberry Pi
filtered = { [1]: [2] for [3] in sensors if sensors[[3]] > 30 }
Drag options to blanks, or click blank then click option'
Asensor.upper()
Bsensors[sensor]
Csensor
Dreading
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong variable names for keys or values.
Not converting sensor names to uppercase.