A must be correct. "response,json()" the comma must be a typo and should be a dot, because all other answer are clearly wrong.
B & D make the same mistake: 'hostname' is not a child element of 'family'.
C has no semicolons in the square brackets.
"Json.loads(response.text)" and "response.json()" --> both methods are used to convert a Json string into a python dictionary.
Options A,C & D are incorrect:
C& D are missing quotation marks
A&D are using the "family" key to access the value for the "hostname" key, but "hostname" key isn't a nested key of the "family" key.
Correction: I meant B & D are using the "family" key to access the value for the "hostname" key, but "hostname" key isn't a nested key of the "family" key.
Option B,C & D are incorrect.
{
"response":[{
"family": "Switches",
"macAddress": "00:4141:43:07:00",
"hostname": "SwitchIDF14",
"upTime": "352 days, 6:17:26:10",
"lastUpdate": "2020-07-12 21:15:29",
}]
}
print ("the family name is ", json_data['response'][0]['family'])
the family name is Switches
or
print ("the hostname name is ", json_data['response'][0]['hostname'])
the hostname name is SwitchIDF14
A is the answer
It is A indeed. First we need to make a python dict so response.json() and use it for printing.
json_data = {
"response": [{
"family": "Switches",
"macAddress": "ff:ff:ff:ff:ff:ff",
"hostname": "SwitchDF14"
}]
}
print("The hostname is: ",json_data['response'][0]['hostname'])
The hostname is: SwitchDF14
This section is not available anymore. Please use the main Exam Page.350-401 Exam Questions
Log in to ExamTopics
Sign in:
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.
Caradum
Highly Voted 2 years, 5 months agoAbdullahMohammad251
Most Recent 7 months, 4 weeks agoAbdullahMohammad251
7 months, 4 weeks ago[Removed]
11 months, 2 weeks agoLanreDipeolu
1 year, 8 months agomsstanick
1 year, 10 months agolandgar
2 years, 3 months agoattiko
2 years, 6 months agojhonelo2011
2 years, 7 months agokebkim
2 years, 7 months ago