exam questions

Exam 350-901 All Questions

View all questions & answers for the 350-901 exam

Exam 350-901 topic 1 question 100 discussion

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

{'lat': 37.4180951010362, 'lng': -122.098531723022, 'address': '', 'serial': 'Q2HP-F5K5-F98Q',
'mac': '88:15:44:ea:f5:bf', 'lanIp': '10.10.10.15',
'url': 'https://n149.meraki.com/DevNet-Sandbox/n/EFZDavc/manage/nodes/new_list/78214561218351',
'model': 'MS220-8P', 'switchProfileId': None, 'firmware': 'switch-11-31', 'floorPlanId': None}
Refer to the exhibit. A developer needs to find the geographical coordinates of a device on the network L_397561557481105433 using a Python script to query the Meraki API. After running response = requests.get() against the Meraki API, the value of response.text is shown in the exhibit.
What Python code is needed to retrieve the longitude and latitude coordinates of the device?

  • A. latitude = response.text['lat'] longitude = response.text['lng']
  • B. latitude = response.json()['lat'] longitude = response.json()['lng']
  • C. latitude = response.json()[0] longitude = response.json()[1]
  • D. latitude = response.text[0] longitude = response.text[1]
Show Suggested Answer Hide Answer
Suggested Answer: B 🗳️

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
__al__
Highly Voted 2 years, 9 months ago
Selected Answer: B
The correct answer is B. See why in my other commend in this discussion.
upvoted 10 times
CiscoRider
2 years, 8 months ago
Dude, response.json()['lat'] does not exist, this is an invalid call. Instead, A, has a proper call for a dictionary using the index or key.
upvoted 3 times
CiscoRider
2 years, 7 months ago
I would like to take my words back. The correct answer as suggested is B. Please review the following example: >>> import requests >>> response = requests.get('https://api.github.com') >>> print(response) <Response [200]> >>> print(response.json()) {'current_user_url': 'https://api.github.com/user', snip... >>> print(response.json()['current_user_url']) https://api.github.com/user >>> print(response.text['current_user_url']) Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: string indices must be integers >>> print(response.json()[0]) Traceback (most recent call last): File "<stdin>", line 1, in <module> KeyError: 0
upvoted 4 times
...
...
...
__al__
Highly Voted 2 years, 10 months ago
the 'text' property of a Response object returs the dictionary as a string, but it is NOT the dictionary itself. >>> import requests >>> publicapi = requests.get(url="https://api.publicapis.org/entries") >>> publicapi.text '{"count":1418,"entries":[{"API":"AdoptAPet","Description":"Resource to help get pets adopted","Auth":"apiKey" (...) ' >>> type(publicapi.text) <class 'str'> >>> type(publicapi.json()) <class 'dict'>
upvoted 7 times
...
samael666
Most Recent 1 week, 1 day ago
Selected Answer: B
correct answe
upvoted 1 times
...
Amycert
4 months ago
Selected Answer: B
answer is B. For A, this will give an error: "response.text['lat']"
upvoted 1 times
...
johntermlen
1 year, 5 months ago
Selected Answer: A
The response.json() method will return the JSON object that was returned by the Meraki API. The 'lat' and 'lng' properties of the JSON object contain the latitude and longitude coordinates of the device.
upvoted 1 times
johntermlen
1 year, 5 months ago
I wanted to say B
upvoted 2 times
...
...
ballastleaf8
1 year, 6 months ago
Selected Answer: B
json() used to read the JSON response. No list in the exhibit so [0] invalid in C
upvoted 2 times
...
xChdjdufurpew
1 year, 10 months ago
Answer is B. You can't parse a String. You must convert the response into a dictionary first.
upvoted 1 times
...
designated
2 years, 4 months ago
Selected Answer: B
B is correct, we need to use json and there is no arrays to select.
upvoted 1 times
...
QuiShong
2 years, 7 months ago
Selected Answer: B
Agree with __al__, the answer is B. The text method returns text and not a dictionary. What you see there is a JSON string and not a dict.
upvoted 1 times
...
RukiaTester
2 years, 10 months ago
A is correct. Just a simple Python question. >>> coordinates = {'lat': 37.4180951010362, 'lng': -122.098531723022, 'address': '', 'serial': 'Q2HP-F5K5-F98Q','mac': '88:15:44:ea:f5:bf', 'lanIp': '10.10.10.15','url': 'https://n149.meraki.com/DevNet-Sandbox/n/EFZDavc/manage/nodes/new_list/78214561218351','model': 'MS220-8P', 'switchProfileId': None, 'firmware': 'switch-11-31', 'floorPlanId': None} >>> latitude = coordinates['lat'] >>> print (latitude) 37.4180951010362 >>> longitude = coordinates['lng'] >>> print (longitude) -122.098531723022
upvoted 1 times
__al__
2 years, 10 months ago
You are assuming that because the output is dictionary-like, then it is a dictionary. And in this case, you are very much wrong. As the name implies, the .text property indeed is a text... a string. See my full comment
upvoted 1 times
...
...
Johnno26
3 years ago
Selected Answer: A
A is correct: response.text is clearly a Python dict, it can be queried as such
upvoted 3 times
__al__
2 years, 9 months ago
Wrong. Response.text is a string representation of a python dictionary. The python dictionary itself is accessible via response.json()
upvoted 2 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