nerdexam
Cisco

350-401 · Question #696

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

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.

Exhibits

350-401 question #696 exhibit 1
350-401 question #696 exhibit 2

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)

How the community answered

(63 responses)
  • A
    5% (3)
  • B
    6% (4)
  • C
    87% (55)
  • D
    2% (1)

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 Practice