Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to start logging sensor data every minute.
SCADA systems
scheduler.schedule_task(sensor.read_data, interval=[1]) Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 30 or 10 seconds instead of 60 seconds.
✗ Incorrect
The interval is set in seconds. To log data every minute, use 60 seconds.
2fill in blank
mediumComplete the code to filter data points where temperature is above the threshold.
SCADA systems
filtered_data = [d for d in data if d.temperature [1] threshold]
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using '<' or '<=' which select lower temperatures.
✗ Incorrect
We want data points where temperature is greater than the threshold.
3fill in blank
hardFix the error in the code to calculate the average value of sensor readings.
SCADA systems
average = sum(readings) [1] len(readings)
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using '*' or '+' which do not compute average.
✗ Incorrect
To find the average, divide the sum by the number of readings.
4fill in blank
hardFill both blanks to create a dictionary of sensor IDs and their latest values.
SCADA systems
latest_values = {sensor.[1]: sensor.[2] for sensor in sensors} Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using timestamp or status instead of id or value.
✗ Incorrect
The dictionary keys are sensor IDs and values are the latest sensor readings.
5fill in blank
hardFill all three blanks to filter and report sensors with values above threshold.
SCADA systems
report = {sensor.[1]: sensor.[2] for sensor in sensors if sensor.[3] > threshold} Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using status or timestamp instead of value for filtering or reporting.
✗ Incorrect
The report maps sensor IDs to their values, filtering those with values above the threshold.