Applications
Complete Final Assessment (Qns & Ans)
2025
Question 1 (Multiple Choice)
Case:
A system administrator has developed a long‑running Python
script that monitors server resources. Since the script must run
continuously and interact with network services, it may
occasionally experience transient errors. The administrator wants
the script to log any such errors and automatically recover without
crashing.
Question:
Which error‑handling mechanism is most appropriate to ensure
robust logging and recovery in this scenario?
©2025
,A. A bare `except` clause that catches all exceptions without
logging
B. A `try/except` block that specifically catches transient errors,
logs the error, and then pauses before retrying
C. Terminating the script immediately upon encountering any
exception
D. Using `try/except` and calling `sys.exit()` after logging the
error
Correct ANS: B. A `try/except` block that specifically
catches transient errors, logs the error, and then pauses before
retrying
Rationale:
Option B isolates only the expected transient exceptions, logs
relevant details for later review, and uses a retry mechanism
(often via a sleep‑backoff) to maintain continuous operation. This
approach prevents the entire application from crashing while still
capturing error information for debugging.
---
Question 2 (Fill in the Blank)
Case:
©2025
,A developer is organizing utility functions into separate files to
promote code reuse and modularity in a Python application. To
use the functions defined in another file, the appropriate
mechanism must be invoked.
Statement:
To include definitions from an external module in Python, the
developer uses the ______ keyword.
Correct ANS: import
Rationale:
The `import` directive in Python allows one file (module) to
include code from another. This practice promotes reuse and clean
separation of functionality across the application.
---
Question 3 (True/False)
Case:
A Node.js developer replaces synchronous file I/O functions with
their asynchronous counterparts to improve application
responsiveness.
©2025
, Statement:
Asynchronous non‑blocking I/O in Node.js enables the event loop
to service multiple network requests concurrently, thereby
improving overall performance.
Correct ANS: True
Rationale:
Node.js relies on an event‑driven non‑blocking I/O model. This
design allows the application to handle many requests
simultaneously without being stalled by slow operations, thereby
enhancing performance and scalability.
---
Question 4 (Multiple Response)
Case:
A developer is using Python's asynchronous programming
features to build a web scraper that collects data from multiple
websites concurrently. This involves restructuring the code using
`async` and `await`.
©2025