Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to register a new device in the registry.
IOT Protocols
registry.register_device(device_id=[1]) Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Forgetting to put quotes around the device ID.
✗ Incorrect
The device ID must be a string, so it needs quotes around it.
2fill in blank
mediumComplete the code to provision a device using the correct method.
IOT Protocols
provisioning_client.[1](device_id) Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using methods that manage devices but don't provision them.
✗ Incorrect
The method to start device provisioning is provision_device.
3fill in blank
hardFix the error in the code to fetch device info from the registry.
IOT Protocols
device_info = registry.get_device([1]) Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Passing the device ID as a string literal instead of a variable.
✗ Incorrect
The method expects a variable holding the device ID, not a string literal.
4fill in blank
hardFill both blanks to create a dictionary of devices filtered by status.
IOT Protocols
filtered_devices = {device: info for device, info in registry.devices.items() if info['[1]'] == '[2]'} Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong keys or status values in the filter.
✗ Incorrect
The dictionary filters devices where the status is active.
5fill in blank
hardFill all three blanks to create a registry update for devices with low battery.
IOT Protocols
low_battery_devices = { [1]: [2] for [1] , [2] in registry.devices.items() if [2]['battery'] < 20 } Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using inconsistent variable names in the comprehension.
✗ Incorrect
The dictionary comprehension uses device as the key and info as the value for devices with battery less than 20.