nerdexam
CiscoCisco

300-435 · Question #150

300-435 Question #150: Real Exam Question with Answer & Explanation

First blank: auth Second blank: x Third blank: connections Fourth blank: items Full code snippet with blanks filled: from vmanage.api.authentication import Authentication from vmanage.api.monitor_network import MonitorNetwork import os auth = Authentication( host=os.environ.get("

Network Automation Foundation

Question

Complete the Python code snippet by filling in the blanks to correctly extract and print connection information.

Explanation

First blank: auth Second blank: x Third blank: connections Fourth blank: items

Full code snippet with blanks filled: from vmanage.api.authentication import Authentication from vmanage.api.monitor_network import MonitorNetwork import os

auth = Authentication( host=os.environ.get("VMANAGE_HOST"), user=os.environ.get("VMANAGE_USERNAME"), password=os.environ.get("VMANAGE_PASSWORD"), validate_certs=False, ).login()

monitor = MonitorNetwork(auth, os.environ.get("VMANAGE_HOST")) response = monitor.get_control_connections("1.1.1.9")

connections = {k["public-ip"]: [k["state"], k["uptime"]] for x in response for d in x}

for k, v in connections.items(): print(f"{k} = {v}")

The script passes the authentication object (auth) to the MonitorNetwork class. It iterates over x in response to build the connections dictionary. The final for-loop uses .items() to print key-value pairs.

Topics

#Python#Data structures#Dictionary traversal#Data extraction

Community Discussion

No community discussion yet for this question.

Full 300-435 PracticeBrowse All 300-435 Questions