📖 Scenario: You work in a factory that uses a SCADA system to monitor energy consumption of different machines. You want to create a simple report that shows the energy usage of each machine and highlights those that consume more than a certain threshold.
🎯 Goal: Build a small program that stores energy consumption data for machines, sets a threshold for high usage, filters machines exceeding that threshold, and prints a report listing those machines.
📋 What You'll Learn
Create a dictionary with machine names and their energy consumption values
Add a threshold variable to define high energy usage
Use a loop or comprehension to find machines exceeding the threshold
Print a clear report listing high energy usage machines
💡 Why This Matters
🌍 Real World
Factories and plants use SCADA systems to monitor energy consumption of machines to save costs and improve efficiency.
💼 Career
DevOps and operations engineers often write scripts to analyze and report system metrics like energy usage for better resource management.
Progress0 / 4 steps
1
Create energy consumption data
Create a dictionary called energy_usage with these exact entries: 'Pump1': 120, 'Conveyor2': 85, 'Furnace3': 200, 'Compressor4': 95, 'Mixer5': 130
SCADA systems
Hint
Use curly braces to create a dictionary with the exact machine names as keys and their energy values as integers.
2
Set high usage threshold
Create a variable called high_usage_threshold and set it to 100 to define the energy consumption limit for high usage.
SCADA systems
Hint
Just assign the number 100 to the variable named high_usage_threshold.
3
Find machines exceeding threshold
Create a dictionary called high_usage_machines using a dictionary comprehension that includes only machines from energy_usage with values greater than high_usage_threshold.
SCADA systems
Hint
Use a dictionary comprehension with for machine, usage in energy_usage.items() and filter with if usage > high_usage_threshold.
4
Print high usage report
Write a print statement that outputs the string "High energy usage machines:" and then a for loop that prints each machine and its usage from high_usage_machines in the format "Machine: usage kWh".
SCADA systems
Hint
Print the header first, then loop over high_usage_machines.items() and print each machine and usage using an f-string.
Practice
(1/5)
1. What is the main purpose of energy management reporting in SCADA systems?
easy
A. To track and display energy usage clearly
B. To control machine speed directly
C. To backup system configurations
D. To monitor network traffic
Solution
Step 1: Understand energy management reporting
Energy management reporting focuses on tracking and showing energy use clearly to help users understand consumption.
Step 2: Compare options to purpose
Options A, B, and D relate to backup, control, and network, which are not the main goals of energy reporting.
Final Answer:
To track and display energy usage clearly -> Option A
Quick Check:
Energy reporting = clear energy tracking [OK]
Hint: Energy reports show usage clearly, not control or backup [OK]
Common Mistakes:
Confusing reporting with control functions
Thinking reports manage network or backups
Ignoring the focus on energy data
2. Which of the following is the correct way to specify a time range for an energy report in a SCADA system configuration?
easy
A. "time-range": 24
B. "timerange": "24hours"
C. "time_range": "last_24_hours"
D. "time range" = "day"
Solution
Step 1: Identify correct JSON key and value format
The correct key uses underscore and quotes: "time_range" and the value is a string like "last_24_hours".
Step 2: Check syntax correctness
Options B, C, and D have syntax errors or wrong key formats (missing quotes, wrong separators).
Final Answer:
"time_range": "last_24_hours" -> Option C
Quick Check:
Correct JSON key and string value = "time_range": "last_24_hours" [OK]
Hint: Use quotes and underscores for JSON keys and string values [OK]
A. Voltage and current data from the main meter for the last 24 hours
B. Voltage and current data from all meters for the last day
C. Only current data from the main meter for the last hour
D. Voltage and current data from the main meter for the last hour
Solution
Step 1: Analyze data_source and metrics
The data_source is "main_meter" and metrics are ["voltage", "current"], so both voltage and current from main_meter are included.
Step 2: Check time_range value
The time_range is "last_1_hour", so data is from the last one hour only.
Final Answer:
Voltage and current data from the main meter for the last hour -> Option D
Quick Check:
Metrics + source + time range match Voltage and current data from the main meter for the last hour [OK]
Hint: Match metrics, source, and time range exactly [OK]
Common Mistakes:
Confusing time ranges (1 hour vs 24 hours)
Ignoring the specified data source
Selecting only one metric instead of both
4. You wrote this report schedule configuration:
{
"schedule": "daily",
"time": 25:00
}
What is the problem with this configuration?
medium
A. The time value 25:00 is invalid; hours must be 0-23
B. The schedule key should be "frequency" instead of "schedule"
C. The time value should be a number, not a string
D. The daily schedule is not supported in SCADA systems
Solution
Step 1: Check time format validity
Time values must be in 24-hour format with hours from 0 to 23. 25:00 is invalid.
Step 2: Verify other keys and values
The "schedule" key is valid, and daily schedules are supported. Time should be a string with quotes.
Final Answer:
The time value 25:00 is invalid; hours must be 0-23 -> Option A
Quick Check:
Invalid hour in time = The time value 25:00 is invalid; hours must be 0-23 [OK]
Hint: Use 24-hour time with hours 0-23 only [OK]
Common Mistakes:
Using hours above 23 in time
Omitting quotes around time string
Confusing schedule key names
5. You want to create a weekly energy report that shows total energy consumption and average power for multiple meters, but only for weekdays. Which configuration snippet correctly sets this up?
{
"data_source": ["meter1", "meter2"],
"metrics": ["total_energy", "average_power"],
"time_range": "last_7_days",
"filter": "weekdays"
} correctly uses a list for multiple meters and metrics, which is the proper format.
Step 2: Verify time_range and filter usage
{
"data_source": ["meter1", "meter2"],
"metrics": ["total_energy", "average_power"],
"time_range": "last_7_days",
"filter": "weekdays"
} uses "last_7_days" for time_range and "filter": "weekdays" to limit data to weekdays, which matches the requirement.
Step 3: Confirm schedule presence
Schedule is not mandatory here; filtering weekdays within last 7 days is sufficient.