200-901 exam dumps

200-901 practice question 1 of 204

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

200-901 Question 1

Single answer

A development team is building a Python application that interacts with a REST API to retrieve network device information. The application must handle potential errors, such as network timeouts or invalid responses, without crashing. Which coding practice should the team implement to ensure robust error handling?

  1. A

    Use try-except blocks to catch specific exceptions, such as requests.Timeout or requests.ConnectionError.

  2. B

    Avoid using error handling mechanisms to keep the code simple and focus on successful cases.

  3. C

    Implement a while loop to continuously retry the request without any condition.

  4. D

    Ignore errors and rely on the application users to report issues manually.

Show answer and explanation

Correct answer: A

Explanation

The use of try-except blocks is a key practice in Python development for handling exceptions. In the context of interacting with a REST API, it is important to anticipate and handle known issues like timeouts or connection errors. This ensures the application can provide meaningful feedback to the user or retry operations gracefully, enhancing application reliability.

  • A. Correct.

    Using try-except blocks allows the application to handle specific exceptions, such as timeouts or connection errors, ensuring the program can recover gracefully or provide meaningful feedback to the user.

  • B. Incorrect.

    Avoiding error handling mechanisms can lead to unhandled exceptions, causing the application to crash and providing a poor user experience.

  • C. Incorrect.

    Using a while loop without conditions can result in infinite retries, consuming resources unnecessarily and potentially causing further issues.

  • D. Incorrect.

    Ignoring errors and relying on users to report issues is not a best practice as it does not ensure robust or proactive error handling, leading to a poor user experience.

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