exam questions

Exam 200-901 All Questions

View all questions & answers for the 200-901 exam

Exam 200-901 topic 1 question 88 discussion

Actual exam question from Cisco's 200-901
Question #: 88
Topic #: 1
[All 200-901 Questions]

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

  • A. response.status_code == requests.codes.ok
  • B. response.code == requests.codes.ok
  • C. response.status_code == requests.ok
  • D. response.status_code != requests.codes.ok
Show Suggested Answer Hide Answer
Suggested Answer: A 🗳️
Reference:
https://realpython.com/python-requests/

Comments

Chosen Answer:
This is a voting comment (?). It is better to Upvote an existing comment if you don't have anything to add.
Switch to a voting comment New
afsarmahmood
Highly Voted 2 years, 3 months ago
A is the right answer.
upvoted 17 times
...
anagy11
Most Recent 7 months, 2 weeks ago
Here's a list of all codes referenced by name in the .codes object: https://2.python-requests.org/en/master/api/#status-code-lookup "Some codes have multiple names, and both upper- and lower-case versions of the names are allowed. For example, codes.ok, codes.OK, and codes.okay all correspond to the HTTP status code 200."
upvoted 1 times
...
designated
8 months, 2 weeks ago
Selected Answer: A
A is correct response.status_code == requests.code.ok response + status_code from library equals requests imported . code from requets library and response code ok
upvoted 1 times
...
psyborg
2 years, 2 months ago
correct, but not pythonic: >>> if response.status_code == requests.codes.ok: ... print("ok") ... ok >>> if response.status_code: ... print("ok") ... ok >>>
upvoted 4 times
Iamrandom
11 months ago
Wrong. Every status code, not only 200, would trigger that condition.
upvoted 3 times
...
...
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.

Upvoting a comment with a selected answer will also increase the vote count towards that answer by one. So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.

SaveCancel
Loading ...
exam
Someone Bought Contributor Access for:
SY0-701
London, 1 minute ago