200-901 exam dumps

200-901 practice question 57 of 204

Cisco DevNet Associate. Associate level, Cisco. Free question with the correct answer and a full explanation.

200-901 Question 57

Single answer

You are tasked with writing a Python script to retrieve a list of devices connected to a Cisco network using the Cisco DNA Center SDK. According to the SDK documentation, the method devices.get_device_list() from the dnacentersdk library can be used. Which of the following snippets correctly uses the SDK to retrieve the list of devices?

  1. A

    from dnacentersdk import api sdk = api.DNACenterAPI(base_url='https://dnacenter.example.com', username='admin', password='password', verify=False) response = sdk.devices.get_device_list() print(response)

  2. B

    import dnacentersdk sdk = dnacentersdk.DNACenter(base_url='https://dnacenter.example.com', username='admin', password='password') response = sdk.devices.list_devices() print(response)

  3. C

    from dnacentersdk import api sdk = api.DNACenterAPI(base_url='https://dnacenter.example.com', username='admin', password='password', verify=True) devices = sdk.network.get_all_devices() print(devices)

  4. D

    from dnacentersdk import api sdk = api.DNACenterAPI(base_url='https://dnacenter.example.com', username='admin', password='password', verify=False) response = sdk.devices.get_device_list() print(response.json())

Show answer and explanation

Correct answer: A

Explanation

The correct script follows the SDK documentation by importing the dnacentersdk library, initializing the DNACenterAPI object with the correct parameters, and using the method get_device_list() to retrieve the list of devices. The response is then printed directly without unnecessary modifications.

  • A. Correct.

    This is the correct script. It correctly imports the dnacentersdk library, initializes the DNACenterAPI object with the required parameters, and calls the appropriate get_device_list() method to retrieve the list of devices. The print(response) outputs the response correctly.

  • B. Incorrect.

    This script has an incorrect import and initialization. The class DNACenter is not a valid class in the dnacentersdk library, and the method list_devices() does not exist.

  • C. Incorrect.

    This script incorrectly calls a non-existent method get_all_devices() under the network object of the SDK. The network object does not provide functionality for retrieving devices.

  • D. Incorrect.

    This script contains an incorrect usage of the .json() method on the response object. The get_device_list() method in the dnacentersdk library already returns a Python dictionary, so calling .json() is unnecessary and will cause an error.

Timed practice exam

Take a 200-901 practice test under exam conditions

75 questions in 120 minutes, drawn from this bank, with a score report and a per-question review when you finish.

Start timed exam