300-435 · Question #19
Refer to the exhibit. The goal is to write a Python script to automatically send a message to an external messaging application when a rogue AP is detected on the network. The message should include…
The correct answer is D. bssids = return_val["alertData"]["bssids"] for value in bssids: send_to_application ("ALERT: detected a bssid on the network: "+value). To access the list of BSSIDs nested within 'alertData' in the return_val dictionary, correctly chain dictionary key access and then iterate through the list.
Question
Options
- Abssids = return_val["bssids"] for number in range(return_val["countNode"]): send_to_application("ALERT: detected a bssid on the network: "+ return_val["alertData"][bssids][number])
- Bbssids = return_val["bssids"] for value in bssids: send_to_application("ALERT: detected a bssid on the network: "+value)
- Ccount = retutn_val["alertData"]["countNode"] bssids = return_val["alertData"][count]["bssids"] for value in bssids: send_to_application ("ALERT: detected a bssid on the network: "+value)
- Dbssids = return_val["alertData"]["bssids"] for value in bssids: send_to_application ("ALERT: detected a bssid on the network: "+value)
How the community answered
(17 responses)- A12% (2)
- C6% (1)
- D82% (14)
Why each option
To access the list of BSSIDs nested within 'alertData' in the `return_val` dictionary, correctly chain dictionary key access and then iterate through the list.
This choice incorrectly tries to access `bssids` directly from `return_val` instead of `return_val["alertData"]`, and the indexing `return_val["alertData"][bssids][number]` is also incorrect for iterating the list.
This choice incorrectly accesses `bssids` directly from `return_val`, missing the "alertData" nesting, which would result in a KeyError.
This choice contains a typo (`retutn_val`), and `return_val["alertData"][count]["bssids"]` attempts to use the `count` variable as a key, which is incorrect for accessing the `bssids` list.
The BSSIDs list is nested under `alertData` and then `bssids`, so `return_val["alertData"]["bssids"]` correctly accesses the list of BSSIDs. The `for value in bssids:` loop then iterates through each SSID in the list and constructs the alert message for the `send_to_application` function.
Concept tested: Python dictionary nesting and iteration
Source: https://docs.python.org/3/tutorial/datastructures.html#dictionaries
Topics
Community Discussion
No community discussion yet for this question.