Problem Definition and Input-Output Mapping Profiles
π·οΈ Final Capstone Engineer Script project / Planning an Automation Script
π§ Context Introduction
Before writing a single line of code, every successful automation script starts with a clear understanding of what problem we are solving and what data flows in and out. This planning phase saves hours of debugging and rework later. Think of it as drawing a blueprint before building a houseβyou need to know where the doors, windows, and pipes go before you start hammering nails.
π΅οΈ What is Problem Definition?
Problem definition is simply writing down what your script needs to accomplish in plain language. It answers three core questions:
- What is the current manual process? (e.g., "We manually check 50 server logs every morning")
- What pain point exists? (e.g., "It takes 2 hours and we often miss critical errors")
- What does success look like? (e.g., "A script that scans all logs in 5 minutes and emails a summary")
A well-defined problem statement acts as your north star throughout development. It keeps you focused and prevents "scope creep"βwhen your script tries to do too many things and ends up doing none of them well.
π Input-Output Mapping Profiles Explained
Every script has inputs (what goes in) and outputs (what comes out). Mapping these before coding is like knowing your ingredients and your final dish before you start cooking.
Common input types you will encounter: - Command-line arguments β values passed when running the script (e.g., a filename or server IP) - Configuration files β settings stored in YAML, JSON, or INI format - Environment variables β system-level values like API keys or paths - User prompts β interactive questions asked during script execution - File reads β data pulled from CSV, log files, or databases
Common output types you will produce: - Console messages β text printed to the terminal for real-time feedback - Report files β structured outputs like CSV summaries or HTML dashboards - Log files β timestamped records of what the script did - API responses β data sent to other systems or services - Status codes β simple success/failure indicators
βοΈ The Input-Output Mapping Table
A simple table helps you visualize the data flow before writing any code. Here is an example for a script that checks disk space across multiple servers:
| Input | Source | Format | Output | Destination |
|---|---|---|---|---|
| Server list | Command-line argument | Comma-separated IPs | Disk usage per server | Console output |
| Threshold value | Environment variable | Integer (percentage) | Alert if threshold exceeded | Log file |
| SSH credentials | Config file (YAML) | Username/password | Connection status | Console message |
| Timestamp | System clock | ISO format | Report header | CSV report file |
This table forces you to think about where data comes from, what shape it is in, and where it needs to go. It also reveals missing pieces earlyβlike realizing you forgot to plan for error messages.
π οΈ Step-by-Step Approach to Problem Definition
Follow these steps for every script you plan:
Step 1 β Write the problem in one sentence Keep it tight. Example: "Automate the daily backup verification report for 200 virtual machines."
Step 2 β List all inputs you can think of Brainstorm everything the script might need. Start broad, then refine. Include edge cases like "what if the input file is empty?"
Step 3 β Define all expected outputs Be specific about format, location, and content. "A CSV file with three columns: VM name, backup status, timestamp."
Step 4 β Identify failure scenarios What happens when an input is missing? When a server is unreachable? When the output directory doesn't exist? Document these now.
Step 5 β Create your input-output mapping table Use the format shown above. This becomes your reference document during coding.
π Real-World Example: Log Parser Script
Let's walk through a concrete example to tie everything together.
Problem Statement: "Our team manually searches through 20 application log files each morning to find ERROR and CRITICAL entries. This takes 45 minutes and we sometimes miss entries. We need a script that scans all logs, extracts high-severity entries, and produces a summary report."
Inputs identified: - Directory path containing log files (command-line argument) - Log file name pattern (hardcoded or configurable) - Severity levels to search for (config file) - Date range filter (optional, command-line argument)
Outputs identified: - Summary report printed to console with count of errors found - Detailed CSV file with timestamp, severity, source file, and message - Log file of script execution (start time, files scanned, errors encountered)
Input-Output Mapping Table:
| Input | Source | Format | Output | Destination |
|---|---|---|---|---|
| Log directory path | Command-line argument | String path | File list summary | Console |
| Severity levels | Config file (JSON) | List of strings | Filtered entries | CSV report |
| Date range | Command-line argument | YYYY-MM-DD format | Execution log | Log file |
| Log file contents | File system | Plain text | Error count | Console |
β Key Takeaways for Your Script Planning
- Start with the problem, not the code. A clear problem statement prevents wasted effort.
- Map inputs and outputs before writing anything. This reveals hidden requirements and edge cases.
- Use a mapping table as your blueprint. It is simple, visual, and catches gaps early.
- Plan for failures, not just happy paths. Robust scripts handle missing files, bad data, and network issues gracefully.
- Keep your mapping document updated. As requirements change, update your table before changing your code.
π Next Steps
With your problem defined and input-output mapping complete, you are ready to move into script structure designβdeciding how to organize your code into functions, where to place error handling, and how to make the script reusable across different environments. A solid plan now means smoother coding later.
This section shows how to define what a script must do by mapping its inputs to expected outputs before writing the full solution.
π§ Example 1: Single input, single output β temperature conversion
This example maps one Celsius input to one Fahrenheit output.
celsius_input = 25
fahrenheit_output = (celsius_input * 9/5) + 32
π€ Output: 77.0
π§ Example 2: Two inputs, one output β pipe flow rate
This example maps pipe diameter and velocity to a flow rate result.
diameter_m = 0.1
velocity_m_per_s = 2.5
area_m2 = 3.14159 * (diameter_m / 2) ** 2
flow_rate_m3_per_s = area_m2 * velocity_m_per_s
π€ Output: 0.0196349375
π§ Example 3: One input, multiple outputs β beam stress analysis
This example maps a single load value to both bending moment and shear force.
load_N = 5000
beam_length_m = 3.0
bending_moment_Nm = (load_N * beam_length_m) / 4
shear_force_N = load_N / 2
π€ Output: bending_moment_Nm = 3750.0, shear_force_N = 2500.0
π§ Example 4: Multiple inputs, conditional output β pressure vessel check
This example maps pressure and radius to a safety status based on a threshold.
internal_pressure_Pa = 150000
vessel_radius_m = 0.5
wall_thickness_m = 0.01
stress_Pa = (internal_pressure_Pa * vessel_radius_m) / wall_thickness_m
max_allowed_stress_Pa = 7500000
is_safe = stress_Pa <= max_allowed_stress_Pa
π€ Output: True
π§ Example 5: File-based input mapping β reading sensor data
This example maps a CSV file of sensor readings to a summary output.
sensor_readings = [23.5, 24.1, 22.8, 25.0, 23.9]
average_temperature = sum(sensor_readings) / len(sensor_readings)
max_temperature = max(sensor_readings)
min_temperature = min(sensor_readings)
π€ Output: average_temperature = 23.86, max_temperature = 25.0, min_temperature = 22.8
π Comparison Table: Input-Output Profiles
| Profile Type | Number of Inputs | Number of Outputs | Example Use Case |
|---|---|---|---|
| One-to-One | 1 | 1 | Unit conversion |
| Many-to-One | 2+ | 1 | Flow rate calculation |
| One-to-Many | 1 | 2+ | Beam stress analysis |
| Conditional | 2+ | 1 (boolean) | Safety check |
| Summary | Many | 3+ | Sensor data analysis |
π§ Context Introduction
Before writing a single line of code, every successful automation script starts with a clear understanding of what problem we are solving and what data flows in and out. This planning phase saves hours of debugging and rework later. Think of it as drawing a blueprint before building a houseβyou need to know where the doors, windows, and pipes go before you start hammering nails.
π΅οΈ What is Problem Definition?
Problem definition is simply writing down what your script needs to accomplish in plain language. It answers three core questions:
- What is the current manual process? (e.g., "We manually check 50 server logs every morning")
- What pain point exists? (e.g., "It takes 2 hours and we often miss critical errors")
- What does success look like? (e.g., "A script that scans all logs in 5 minutes and emails a summary")
A well-defined problem statement acts as your north star throughout development. It keeps you focused and prevents "scope creep"βwhen your script tries to do too many things and ends up doing none of them well.
π Input-Output Mapping Profiles Explained
Every script has inputs (what goes in) and outputs (what comes out). Mapping these before coding is like knowing your ingredients and your final dish before you start cooking.
Common input types you will encounter: - Command-line arguments β values passed when running the script (e.g., a filename or server IP) - Configuration files β settings stored in YAML, JSON, or INI format - Environment variables β system-level values like API keys or paths - User prompts β interactive questions asked during script execution - File reads β data pulled from CSV, log files, or databases
Common output types you will produce: - Console messages β text printed to the terminal for real-time feedback - Report files β structured outputs like CSV summaries or HTML dashboards - Log files β timestamped records of what the script did - API responses β data sent to other systems or services - Status codes β simple success/failure indicators
βοΈ The Input-Output Mapping Table
A simple table helps you visualize the data flow before writing any code. Here is an example for a script that checks disk space across multiple servers:
| Input | Source | Format | Output | Destination |
|---|---|---|---|---|
| Server list | Command-line argument | Comma-separated IPs | Disk usage per server | Console output |
| Threshold value | Environment variable | Integer (percentage) | Alert if threshold exceeded | Log file |
| SSH credentials | Config file (YAML) | Username/password | Connection status | Console message |
| Timestamp | System clock | ISO format | Report header | CSV report file |
This table forces you to think about where data comes from, what shape it is in, and where it needs to go. It also reveals missing pieces earlyβlike realizing you forgot to plan for error messages.
π οΈ Step-by-Step Approach to Problem Definition
Follow these steps for every script you plan:
Step 1 β Write the problem in one sentence Keep it tight. Example: "Automate the daily backup verification report for 200 virtual machines."
Step 2 β List all inputs you can think of Brainstorm everything the script might need. Start broad, then refine. Include edge cases like "what if the input file is empty?"
Step 3 β Define all expected outputs Be specific about format, location, and content. "A CSV file with three columns: VM name, backup status, timestamp."
Step 4 β Identify failure scenarios What happens when an input is missing? When a server is unreachable? When the output directory doesn't exist? Document these now.
Step 5 β Create your input-output mapping table Use the format shown above. This becomes your reference document during coding.
π Real-World Example: Log Parser Script
Let's walk through a concrete example to tie everything together.
Problem Statement: "Our team manually searches through 20 application log files each morning to find ERROR and CRITICAL entries. This takes 45 minutes and we sometimes miss entries. We need a script that scans all logs, extracts high-severity entries, and produces a summary report."
Inputs identified: - Directory path containing log files (command-line argument) - Log file name pattern (hardcoded or configurable) - Severity levels to search for (config file) - Date range filter (optional, command-line argument)
Outputs identified: - Summary report printed to console with count of errors found - Detailed CSV file with timestamp, severity, source file, and message - Log file of script execution (start time, files scanned, errors encountered)
Input-Output Mapping Table:
| Input | Source | Format | Output | Destination |
|---|---|---|---|---|
| Log directory path | Command-line argument | String path | File list summary | Console |
| Severity levels | Config file (JSON) | List of strings | Filtered entries | CSV report |
| Date range | Command-line argument | YYYY-MM-DD format | Execution log | Log file |
| Log file contents | File system | Plain text | Error count | Console |
β Key Takeaways for Your Script Planning
- Start with the problem, not the code. A clear problem statement prevents wasted effort.
- Map inputs and outputs before writing anything. This reveals hidden requirements and edge cases.
- Use a mapping table as your blueprint. It is simple, visual, and catches gaps early.
- Plan for failures, not just happy paths. Robust scripts handle missing files, bad data, and network issues gracefully.
- Keep your mapping document updated. As requirements change, update your table before changing your code.
π Next Steps
With your problem defined and input-output mapping complete, you are ready to move into script structure designβdeciding how to organize your code into functions, where to place error handling, and how to make the script reusable across different environments. A solid plan now means smoother coding later.
Interactive Views
You are currently in π All-in-One mode. Use the tabs at the top to switch to π Theory Only or π» Code Only views.
This section shows how to define what a script must do by mapping its inputs to expected outputs before writing the full solution.
π§ Example 1: Single input, single output β temperature conversion
This example maps one Celsius input to one Fahrenheit output.
celsius_input = 25
fahrenheit_output = (celsius_input * 9/5) + 32
π€ Output: 77.0
π§ Example 2: Two inputs, one output β pipe flow rate
This example maps pipe diameter and velocity to a flow rate result.
diameter_m = 0.1
velocity_m_per_s = 2.5
area_m2 = 3.14159 * (diameter_m / 2) ** 2
flow_rate_m3_per_s = area_m2 * velocity_m_per_s
π€ Output: 0.0196349375
π§ Example 3: One input, multiple outputs β beam stress analysis
This example maps a single load value to both bending moment and shear force.
load_N = 5000
beam_length_m = 3.0
bending_moment_Nm = (load_N * beam_length_m) / 4
shear_force_N = load_N / 2
π€ Output: bending_moment_Nm = 3750.0, shear_force_N = 2500.0
π§ Example 4: Multiple inputs, conditional output β pressure vessel check
This example maps pressure and radius to a safety status based on a threshold.
internal_pressure_Pa = 150000
vessel_radius_m = 0.5
wall_thickness_m = 0.01
stress_Pa = (internal_pressure_Pa * vessel_radius_m) / wall_thickness_m
max_allowed_stress_Pa = 7500000
is_safe = stress_Pa <= max_allowed_stress_Pa
π€ Output: True
π§ Example 5: File-based input mapping β reading sensor data
This example maps a CSV file of sensor readings to a summary output.
sensor_readings = [23.5, 24.1, 22.8, 25.0, 23.9]
average_temperature = sum(sensor_readings) / len(sensor_readings)
max_temperature = max(sensor_readings)
min_temperature = min(sensor_readings)
π€ Output: average_temperature = 23.86, max_temperature = 25.0, min_temperature = 22.8
π Comparison Table: Input-Output Profiles
| Profile Type | Number of Inputs | Number of Outputs | Example Use Case |
|---|---|---|---|
| One-to-One | 1 | 1 | Unit conversion |
| Many-to-One | 2+ | 1 | Flow rate calculation |
| One-to-Many | 1 | 2+ | Beam stress analysis |
| Conditional | 2+ | 1 (boolean) | Safety check |
| Summary | Many | 3+ | Sensor data analysis |