PCAP Exceptions and File I/O • Set 3
PCAP Exceptions and File I/O Practice Test 3 — 15 questions with explanations. Free, no signup.
Refer to the exhibit. A developer ran the script and saw the above traceback. The intended behavior was to load a JSON configuration file, and if the file is missing, create a default config. What is the most likely root cause of the second exception (NameError)?
Traceback (most recent call last):
File "app.py", line 9, in <module>
with open("config.json", "r") as f:
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: 'config.json'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "app.py", line 11, in <module>
config = json.load(f)
^^^^^^^^^^^
NameError: name 'json' is not defined