📖 Scenario: You are working as a smart home technician. You need to compare two popular wireless protocols, Zigbee and Z-Wave, to decide which one to use for a new home automation project.
🎯 Goal: Build a simple program that stores key features of Zigbee and Z-Wave, sets a preference threshold, filters protocols based on that threshold, and then displays the selected protocols.
📋 What You'll Learn
Create a dictionary called protocols with keys 'Zigbee' and 'Z-Wave' and their feature scores as values
Add a variable called min_score to set the minimum acceptable feature score
Use a dictionary comprehension to create a new dictionary selected_protocols with protocols having scores greater than or equal to min_score
Print the selected_protocols dictionary
💡 Why This Matters
🌍 Real World
Smart home technicians often compare wireless protocols like Zigbee and Z-Wave to choose the best one for device compatibility and performance.
💼 Career
Understanding how to organize, filter, and display configuration data is essential for IoT device setup and network management.
Progress0 / 4 steps
1
Create the protocols dictionary
Create a dictionary called protocols with these exact entries: 'Zigbee': 8 and 'Z-Wave': 7 representing their feature scores.
IOT Protocols
Hint
Use curly braces to create a dictionary with keys and values.
2
Set the minimum score threshold
Add a variable called min_score and set it to 8 to represent the minimum feature score required.
IOT Protocols
Hint
Just assign the number 8 to the variable min_score.
3
Filter protocols by minimum score
Use a dictionary comprehension to create a new dictionary called selected_protocols that includes only protocols from protocols with scores greater than or equal to min_score. Use for name, score in protocols.items() in your comprehension.
IOT Protocols
Hint
Use the syntax: {key: value for key, value in dict.items() if condition}.
4
Display the selected protocols
Write a print statement to display the selected_protocols dictionary.
IOT Protocols
Hint
Use print(selected_protocols) to show the filtered dictionary.
Practice
(1/5)
1. Which frequency band does Zigbee primarily use for communication?
easy
A. 5 GHz
B. 900 MHz
C. 1.8 GHz
D. 2.4 GHz
Solution
Step 1: Recall Zigbee frequency usage
Zigbee commonly operates on the 2.4 GHz frequency band, which is globally available and supports faster data rates.
Step 2: Compare with other options
900 MHz is used by Z-Wave, 5 GHz and 1.8 GHz are not typical for Zigbee.