📖 Scenario: You are working with a Raspberry Pi connected to a small display screen. You want to understand why displays show visual feedback when you interact with them, like pressing buttons or running programs.
🎯 Goal: Build a simple program that simulates visual feedback by showing messages on the display when certain actions happen.
📋 What You'll Learn
Create a dictionary with actions and their visual feedback messages
Set a variable for the current action
Use a loop to find and display the feedback message for the current action
Print the feedback message to the screen
💡 Why This Matters
🌍 Real World
Displays on devices like Raspberry Pi show visual feedback to help users know what is happening, like confirming a button press or showing errors.
💼 Career
Understanding how to provide visual feedback is important for creating user-friendly interfaces in embedded systems and IoT devices.
Progress0 / 4 steps
1
Create the actions dictionary
Create a dictionary called actions with these exact entries: 'button_press': 'Button pressed!', 'program_start': 'Program is running.', 'error': 'An error occurred.'
Raspberry Pi
Hint
Use curly braces {} to create a dictionary with keys and values separated by colons.
2
Set the current action
Create a variable called current_action and set it to the string 'button_press'
Raspberry Pi
Hint
Assign the string 'button_press' to the variable current_action.
3
Find the feedback message
Use a for loop with variables action and message to iterate over actions.items(). Inside the loop, check if action equals current_action. If yes, assign message to a variable called feedback.
Raspberry Pi
Hint
Use a for loop to check each action and compare it to current_action. When they match, save the message.
4
Display the feedback message
Write print(feedback) to display the feedback message on the screen.
Raspberry Pi
Hint
Use print() to show the feedback message on the screen.
Practice
(1/5)
1. Why do Raspberry Pi displays provide visual feedback to users?
easy
A. To show device status and actions clearly
B. To make the device heavier
C. To increase power consumption
D. To confuse the user
Solution
Step 1: Understand the purpose of visual feedback
Visual feedback helps users see what the device is doing or its current status.
Step 2: Match the purpose with the options
Only To show device status and actions clearly correctly states that visual feedback shows device status and actions clearly.
Final Answer:
To show device status and actions clearly -> Option A
Quick Check:
Visual feedback = show status and actions [OK]
Hint: Visual feedback means showing device status visibly [OK]
Common Mistakes:
Thinking feedback is for decoration only
Confusing feedback with power use
Assuming feedback confuses users
2. Which of the following is the correct way to display text on a Raspberry Pi screen using Python?
easy
A. screen.show('Hello World')
B. print('Hello World')
C. display.text('Hello World')
D. output.write('Hello World')
Solution
Step 1: Identify common Python display command
In Python, print() outputs text to the console or display.
Step 2: Check other options for correctness
Options A, B, and D are not standard Python commands for displaying text.
Final Answer:
print('Hello World') -> Option B
Quick Check:
Python display text = print() [OK]
Hint: Use print() to show text on Raspberry Pi screen [OK]
Common Mistakes:
Using non-existent display commands
Confusing method names
Assuming screen.show() is valid
3. What will be the output on the Raspberry Pi display after running this Python code?
status = 'ON'
if status == 'ON':
print('Device is active')
else:
print('Device is inactive')
medium
A. SyntaxError
B. Device is inactive
C. No output
D. Device is active
Solution
Step 1: Check the value of the variable 'status'
The variable status is set to 'ON'.
Step 2: Evaluate the if condition
The condition status == 'ON' is true, so the first print runs.
Final Answer:
Device is active -> Option D
Quick Check:
status 'ON' triggers 'Device is active' [OK]
Hint: Check variable value before if condition [OK]
Common Mistakes:
Ignoring the if condition
Assuming else runs first
Thinking code has syntax errors
4. Identify the error in this Raspberry Pi Python code that tries to show a message on the display:
message = 'Ready'
print message
medium
A. Missing parentheses in print statement
B. Variable 'message' is not defined
C. Incorrect string quotes
D. No error, code is correct
Solution
Step 1: Check the print syntax
In Python 3, print requires parentheses: print(message).
Step 2: Verify variable and string correctness
The variable message is defined and string quotes are correct.
Final Answer:
Missing parentheses in print statement -> Option A
Quick Check:
Python 3 print needs () [OK]
Hint: Always use parentheses with print() in Python 3 [OK]
Common Mistakes:
Forgetting parentheses in print
Thinking variable is undefined
Confusing string quotes
5. You want your Raspberry Pi display to show a green light symbol when a device is active and a red light symbol when inactive. Which approach best uses visual feedback to help users understand device status?
hard
A. Turn off the display to save power
B. Show only text messages without colors
C. Show green light for active, red light for inactive
D. Display random colors regardless of status
Solution
Step 1: Understand visual feedback purpose
Visual feedback should clearly show device status using recognizable signals like colors.
Step 2: Evaluate options for clarity and usefulness
Show green light for active, red light for inactive uses green and red lights to clearly indicate active/inactive states, helping users understand quickly.
Final Answer:
Show green light for active, red light for inactive -> Option C
Quick Check:
Clear color signals = better visual feedback [OK]
Hint: Use clear color signals for status feedback [OK]
Common Mistakes:
Ignoring color meaning
Using random colors confusing users
Not showing any feedback
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.