
































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!

































socket library and libraries like Paramiko require port numbers as integers, not strings. Failing to convert will raise a TypeError.
D. The port number Answer: B Rationale: gethostbyname() resolves a hostname to its IPv4 address.
C. Set stderr=subprocess.PIPE and inspect the return code manually D. Use subprocess.Popen instead and call communicate() Answer: A Rationale: check=True causes subprocess.run to raise CalledProcessError on non-zero exit, while still capturing output if capture_output=True. It is the minimal, idiomatic fix.
C. API credentials cannot be stored in variables D. APIs require credentials to be entered manually each time Answer: B Rationale: Credentials embedded in source code can be exposed through repositories, backups, logs, or shared files. Environment variables or secure secret-management mechanisms are generally safer.
A. A list of server strings B. A dictionary mapping device names to approved DNS server lists C. A tuple of device names D. An integer Answer: B Rationale: A dictionary allows O(1) lookup of approved DNS servers by device name, making the comparison efficient during the audit.
B. for key, value in dict.items(): C. for value in dict: D. for item in dict: Answer: B Rationale: dict.items() returns key-value pairs, allowing iteration with for key, value in dict.items():.
A. with open('config.json') as f: return f.read()['host'] B. with open('config.json') as f: return json.load(f)['host'] C. return json.loads('config.json')['host'] D. with open('config.json','w') as f: return json.dump(f)['host'] Answer: B Rationale: json.load(f) deserializes a file object into a Python dictionary. json.loads() expects a string, not a filename, and opening in 'w' mode would truncate the file.