A systems analyst is creating a Python script (.py) to monitor storage space and send alert logs when disk usage exceeds a specified threshold. Place the following script components in the correct logical execution sequence from top to bottom.
- 1Shebang directive line declaring the Python interpreter environment (#!/usr/bin/env python3)
- 2Module import statements loading required system libraries (import shutil, import sys)
- 3Environment variable declaration assigning the threshold limit (DISK_THRESHOLD = 85)
- 4Conditional construct evaluating current usage against DISK_THRESHOLD (if usage > DISK_THRESHOLD:)
Answer
The correct logical sequence for the Python script elements from top to bottom is: Shebang directive line declaring the interpreter environment, Module import statements, Environment variable declaration assigning the threshold limit, and Conditional construct evaluating current usage against the threshold.
In scripting languages such as Python or Bash, code executes sequentially from top to bottom. The shebang directive must appear first to define the interpreter environment. Next, required module libraries must be imported so their functions are available. Variable declarations must follow to set initial values and parameters. Finally, conditional constructs and control flow loops run using the initialized variables and imported module methods.
Step-by-Step Solution
Key Concept
Logical structure and execution sequence of basic scripting constructs