Question 3
An engineer must create a script to append and modify device entries in a JSON-formatted file. The script must work as follows:
Until interrupted from the keyboard, the script reads in the hostname of a device, its management IP address, operating system type, and CLI remote access protocol.
After being interrupted, the script displays the entered entries and adds them to the JSON-formatted file, replacing existing entries whose hostname matches.
The contents of the JSON-formatted file are as follows:
Drag and drop the statements onto the blanks within the code to complete the script. Not all options are used.
Correct answer: To work with this question, an Exam Simulator is required.
Explanation:
We tested this code successfully: And this is the result: Note:In Python, "pass" is a null statement. It is usually used as a placeholder.In order to run the code successfully, we must have the "devicesData.json" first with at least one sample.This code runs infinitely with "while True:" so we have to use Keyboard interrupt to exit (Ctrl-C in Windows, for example).
We tested this code successfully:
And this is the result:
Note:
In Python, "pass" is a null statement. It is usually used as a placeholder.
In order to run the code successfully, we must have the "devicesData.json" first with at least one sample.
This code runs infinitely with "while True:" so we have to use Keyboard interrupt to exit (Ctrl-C in Windows, for example).