Developing Applications and Automating Workflows Using Cisco Platforms (DEVASC) — Question 42

In Python, which expression checks whether the script returns a success status code when the Requests library is used?

Answer options

Correct answer: A

Explanation

The correct answer is A because it accurately checks if the status code of the response matches the success status defined by requests.codes.ok. Option B is incorrect as it uses 'response.code' instead of the correct 'response.status_code'. Option C is wrong because it references 'requests.ok', which does not exist, while option D checks for inequality, which does not confirm a successful status.