nerdexam
Cisco

350-401 · Question #840

Drag and Drop Question An engineer plans to use Python to convert text files that contain device information to JSON. Drag and drop the code snippets from the bottom onto the blanks in the code to con

The correct answer is with open(raw-data) as text:; out_file = open("json-Output.json", "w"); out_file.close(out_file). The correct sequence first opens the source text file in read mode using 'with open(raw-data) as text:' to access the device information, then creates the output JSON file in write mode ('w') using 'out_file = open("json-Output.json", "w")', and finally closes the output file wit

Submitted by valeria.br· Mar 6, 2026Cisco DevNet / CCNP Enterprise - Automation and Programmability: Using Python to automate network tasks, including reading device data from text files and converting/writing output to structured formats such as JSON.

Question

Drag and Drop Question An engineer plans to use Python to convert text files that contain device information to JSON. Drag and drop the code snippets from the bottom onto the blanks in the code to construct the request. Not all options are used. Answer:

Exhibit

350-401 question #840 exhibit

Answer Area

Drag items

out_file.close(out_file)with open(raw-data) as text:out_file = open("json-Output.json", "w")out_file = open("json-Output.json", "r")

Correct arrangement

  • with open(raw-data) as text:
  • out_file = open("json-Output.json", "w")
  • out_file.close(out_file)

Explanation

The correct sequence first opens the source text file in read mode using 'with open(raw-data) as text:' to access the device information, then creates the output JSON file in write mode ('w') using 'out_file = open("json-Output.json", "w")', and finally closes the output file with 'out_file.close(out_file)'. This follows the standard Python pattern for reading from one file and writing converted data to another, ensuring proper file handling throughout the process.

Topics

#Python scripting#File I/O#JSON conversion#Network automation

Community Discussion

No community discussion yet for this question.

Full 350-401 Practice