nerdexam
CiscoCisco

350-401 · Question #696

350-401 Question #696: Real Exam Question with Answer & Explanation

The correct answer is C: OutFile = open("devices.json", "w") json.dump(Devices, OutFile) OutFile.close(). Option C is correct because it properly uses json.dump() (not json.dumps()) to serialize the Devices data structure directly into a file object. The json.dump() function takes two arguments: the object to serialize and the file object to write to, which is exactly what OutFile pr

Submitted by akirajp· Mar 6, 2026Network Automation and Programmability - Working with data formats (JSON) and Python scripting for storing and manipulating structured data

Question

Which Python snippet should be used to store the devices data structure in a JSON file? A. B. C. D.

Options

  • Awith open("devices.json", "w") as OutFile: json.dumps(Devices)
  • BOutFile = open("devices.json", "w") OutFile.writestr(Devices)) OutFile.close()
  • COutFile = open("devices.json", "w") json.dump(Devices, OutFile) OutFile.close()
  • Dwith open("devices.json", "w") as OutFile: Devices = json.load(OutFile)

Explanation

Option C is correct because it properly uses json.dump() (not json.dumps()) to serialize the Devices data structure directly into a file object. The json.dump() function takes two arguments: the object to serialize and the file object to write to, which is exactly what OutFile provides after being opened in write mode ('w'). The file is also properly closed after the write operation.

Topics

#Python JSON#File I/O#Data Serialization#json module

Community Discussion

No community discussion yet for this question.

Full 350-401 PracticeBrowse All 350-401 Questions