📖 Scenario: You are working on a simple program to compare two popular microcontroller platforms: Raspberry Pi and Arduino. This will help beginners understand their differences by listing key features side by side.
🎯 Goal: Create a Python dictionary to store features of Raspberry Pi and Arduino, then filter and display features that are unique to Raspberry Pi.
📋 What You'll Learn
Create a dictionary called devices with two keys: 'Raspberry Pi' and 'Arduino'.
Each key should map to a list of features as strings.
Create a variable called unique_to_pi to hold features that are only in Raspberry Pi's list but not in Arduino's.
Print the list unique_to_pi.
💡 Why This Matters
🌍 Real World
Comparing features of hardware platforms helps beginners choose the right tool for their projects.
💼 Career
Understanding differences between microcontrollers and microcomputers is useful for roles in embedded systems and IoT development.
Progress0 / 4 steps
1
Create the devices dictionary
Create a dictionary called devices with these exact entries: 'Raspberry Pi' mapped to the list ["Runs Linux", "Has HDMI output", "Supports WiFi"] and 'Arduino' mapped to the list ["Microcontroller", "No OS", "Low power consumption"].
Raspberry Pi
Hint
Use curly braces {} to create a dictionary. Each key is a string and maps to a list of strings.
2
Create a variable for unique Raspberry Pi features
Create a variable called unique_to_pi and set it to an empty list [].
Raspberry Pi
Hint
Just write unique_to_pi = [] to start with an empty list.
3
Find features unique to Raspberry Pi
Use a for loop with the variable feature to go through devices['Raspberry Pi']. Inside the loop, use an if statement to check if feature is NOT in devices['Arduino']. If so, append feature to unique_to_pi.
Raspberry Pi
Hint
Use for feature in devices['Raspberry Pi']: and inside check if feature not in devices['Arduino']: then append.
4
Print the unique Raspberry Pi features
Write print(unique_to_pi) to display the list of features unique to Raspberry Pi.
Raspberry Pi
Hint
Use print(unique_to_pi) to show the list.
Practice
(1/5)
1. Which device is best described as a mini computer with an operating system?
easy
A. Arduino
B. Raspberry Pi
C. Both Raspberry Pi and Arduino
D. Neither Raspberry Pi nor Arduino
Solution
Step 1: Understand Raspberry Pi's nature
Raspberry Pi runs a full operating system like Linux, making it a mini computer.
Step 2: Compare with Arduino
Arduino is a microcontroller without an operating system, used for simple hardware tasks.
Final Answer:
Raspberry Pi -> Option B
Quick Check:
Mini computer = Raspberry Pi [OK]
Hint: Mini computer with OS? Think Raspberry Pi [OK]
Common Mistakes:
Confusing Arduino as a computer
Thinking both have operating systems
Assuming Arduino runs Linux
2. Which of the following is the correct way to describe Arduino?
easy
A. A microcontroller for simple hardware tasks
B. A mini computer running Windows
C. A smartphone operating system
D. A cloud computing platform
Solution
Step 1: Identify Arduino's function
Arduino is designed as a microcontroller to control hardware simply and directly.
Step 2: Eliminate incorrect options
It does not run Windows, is not an OS, nor a cloud platform.
Final Answer:
A microcontroller for simple hardware tasks -> Option A
Quick Check:
Arduino = microcontroller [OK]
Hint: Arduino controls hardware simply [OK]
Common Mistakes:
Thinking Arduino runs a full OS
Confusing Arduino with cloud services
Assuming Arduino is a computer
3. What will be the output if you try to run a Python script requiring an OS on an Arduino?
medium
A. The script runs successfully
B. Syntax error in the script
C. Runtime error due to missing OS
D. Arduino automatically installs OS and runs script
Solution
Step 1: Understand Arduino's capabilities
Arduino lacks an operating system, so it cannot run Python scripts that require one.
Step 2: Predict the result of running such a script
Trying to run the script causes a runtime error because the OS environment is missing.
Final Answer:
Runtime error due to missing OS -> Option C
Quick Check:
Python script needs OS = runtime error on Arduino [OK]
Hint: No OS means runtime error for OS-dependent scripts [OK]
Common Mistakes:
Assuming Arduino can run Python scripts
Expecting syntax errors instead of runtime errors
Thinking Arduino installs OS automatically
4. You wrote a program to control an LED on Raspberry Pi using Arduino code syntax. What is the likely issue?
medium
A. Syntax error because Raspberry Pi uses different libraries
B. Raspberry Pi automatically converts Arduino code
C. Hardware damage due to incompatible code
D. The program runs perfectly on Raspberry Pi
Solution
Step 1: Recognize code compatibility
Arduino code syntax and libraries differ from Raspberry Pi's Python or Linux-based environment.
Step 2: Identify the error type
Using Arduino code directly on Raspberry Pi causes syntax or library errors.
Final Answer:
Syntax error because Raspberry Pi uses different libraries -> Option A
Quick Check:
Arduino code on Pi = syntax error [OK]
Hint: Arduino code won't run on Pi without changes [OK]
Common Mistakes:
Expecting automatic code conversion
Assuming hardware damage occurs
Thinking code runs perfectly
5. You want to build a home automation system that requires both complex data processing and controlling physical devices. Which setup is best?
hard
A. Use a smartphone app only
B. Use only Raspberry Pi for all tasks
C. Use only Arduino for all tasks
D. Combine Raspberry Pi for processing and Arduino for hardware control
Solution
Step 1: Analyze project needs
Complex data processing requires an OS and computing power, which Raspberry Pi provides.
Step 2: Consider hardware control
Arduino excels at direct hardware control with simple, real-time responses.
Step 3: Combine strengths
Using Raspberry Pi for processing and Arduino for device control leverages both devices effectively.
Final Answer:
Combine Raspberry Pi for processing and Arduino for hardware control -> Option D
Quick Check:
Complex + hardware = Pi + Arduino combo [OK]
Hint: Use Pi + Arduino for complex + hardware tasks [OK]
Common Mistakes:
Choosing only Arduino for complex tasks
Ignoring hardware control needs
Assuming smartphone app replaces hardware
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.