exam questions

Exam 350-401 All Questions

View all questions & answers for the 350-401 exam

Exam 350-401 topic 1 question 312 discussion

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

Based on the output below, which Python code shows the value of the "upTime" key?

  • A. json_data = response.json() print(json_data['response'][0]['upTime'])
  • B. json_data = response.json() print(json_data[response][0][upTime])
  • C. json_data = json.loads(response.text) print(json_data['response']['family']['upTime'])
  • D. json_data = response.json() print(json_data['response'][family]['upTime'])
Show Suggested Answer Hide Answer
Suggested Answer: A 🗳️

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
hsjfjbdlw
Highly Voted 3 years, 6 months ago
The correct answer is A. The dictionary attributes are strings, so they would need to be addressed with quotations. B implies that variables are being specified as the attribute identifiers.
upvoted 26 times
...
MO_2022
Highly Voted 2 years ago
Selected Answer: A
Note: We need to call the first element “[0]” in “json_data[‘response’][0][‘upTime’])” command because “response” is an array with only one element
upvoted 9 times
[Removed]
1 year, 6 months ago
Thank you
upvoted 1 times
...
...
[Removed]
Most Recent 7 months ago
not sure if this is a CCNP question, I think it's just one of the fake questions.
upvoted 1 times
...
Beehurls
8 months, 4 weeks ago
I would be mad to get this question on the exam without seeing it here first. Nothing in the blueprint or cert guide would tell me that I need to know this for the exam.
upvoted 3 times
...
Claudiu1
10 months, 1 week ago
We either need more context here, or all answers are wrong: assuming that the ''response text'' is either a string or a dictionary, A, B and D answers are all wrong because neither str, nor dict have methods called json(). From this perspective, only C is correct because json module in python does have a loads() method which takes a string formatted as a json object and returns a dictionary. However, C does a disastrous job at accessing the 'upTime' key. So C is very wrong.
upvoted 1 times
...
mp777
1 year, 5 months ago
there is no 'family' dictionary inherited. so 'family' options go away. upTime needs to be type string so 'upTime', as there is no other variable upTime. A is correct.
upvoted 1 times
...
HarwinderSekhon
1 year, 6 months ago
Nobody in real life check it with eyes, we all use json formatting tools. Cisco is old school like we are living in old century. Instead ask, how can you format json or what tools can you use.
upvoted 6 times
...
wr4net
1 year, 7 months ago
json is data is typically key:value pairs fo data in a rigid hierarchy, like a tree. key elements at the same level are separated by commas. family and uptime are clear at the same level in the tree. therefore to print uptime, you do not need to reference another same leverl key, such as family. this take out c and d. of a & b, all keys are referenced inside of quotes. so Uptime in quotes takes care of that. As a side note, if uptime were a subtree item falling under family, it would have more brackets in the data element, and in that case the c/d chaining of subtree elements would make senses. but not here.
upvoted 1 times
...
Chiaretta
1 year, 8 months ago
Selected Answer: A
A is the right answer
upvoted 3 times
...
MMaris018
1 year, 8 months ago
Selected Answer: C
json.loads() is used to convert JSON into python
upvoted 3 times
...
juancarlosdlar
1 year, 11 months ago
json.loads() method can be used to parse a valid JSON string and convert it into a Python Dictionary.
upvoted 2 times
...
kewokil120
1 year, 11 months ago
The correct answer is A
upvoted 1 times
...
nushadu
2 years ago
# python code test_dict = {'val1': [{1: 11, 2: 22, 3: 33}]} print(test_dict['val1'][0][3]) # result 33
upvoted 2 times
...
Wooker
2 years, 2 months ago
Selected Answer: A
The correct answer is A
upvoted 4 times
...
BigMouthDog
2 years, 4 months ago
inside the array , i.e. [ ], there is only one item { }, therefore respond refers to [0]
upvoted 2 times
...
BigMouthDog
2 years, 5 months ago
The answer is 'A', because the question is asked about 'UpTime', not 'family', both of them are object within array 'response' ,i.e. [ {"family:xxx", "UpTime:xxx"}...
upvoted 2 times
...
ougty
2 years, 7 months ago
Selected Answer: A
It should be A
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 ...