350-401 · Question #412
350-401 Question #412: Real Exam Question with Answer & Explanation
The correct answer is B: for interface in netconf_data["GigabitEthernet"]: if interface["enabled"] != 'true': print(interface["description"]). Option B is correct because it iterates through all GigabitEthernet interfaces and checks if the 'enabled' field is NOT equal to 'true' (as a string), which effectively filters for disabled interfaces only, then prints their descriptions. In NETCONF/YANG data parsed from XML, boo
Question
Refer to the exhibit. Which Python code snippet prints the descriptions of disabled interfaces only? A. B. C. D.
Options
- Afor interface in netconf_data["GigabitEthernet"]: if interface["enabled"] != 'false': print(interface["description"])
- Bfor interface in netconf_data["GigabitEthernet"]: if interface["enabled"] != 'true': print(interface["description"])
- Cfor interface in netconf_data["GigabitEthernet"]: if interface["disabled"] != 'true': print(interface["description"])
- Dfor interface in netconf_data["GigabitEthernet"]: print(interface["enabled"]) print(interface["description"])
Explanation
Option B is correct because it iterates through all GigabitEthernet interfaces and checks if the 'enabled' field is NOT equal to 'true' (as a string), which effectively filters for disabled interfaces only, then prints their descriptions. In NETCONF/YANG data parsed from XML, boolean values are typically represented as strings ('true' or 'false'), so comparing against the string 'true' is the appropriate approach.
Topics
Community Discussion
No community discussion yet for this question.