Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to store sensor data in the historical database.
SCADA systems
database.insert([1]) Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using current_time instead of the actual data to store.
✗ Incorrect
We insert the sensor_data into the database to keep a record of measurements over time.
2fill in blank
mediumComplete the code to retrieve historical data for analysis.
SCADA systems
historical_data = database.query('SELECT * FROM records WHERE timestamp [1] start_time')
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using <=' which would get records before the start time.
✗ Incorrect
We use >= to get all records from the start_time onwards.
3fill in blank
hardFix the error in the code to archive old historical data.
SCADA systems
archive_data = database.extract('SELECT * FROM records WHERE timestamp [1] cutoff_date')
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using > which selects newer data instead of old data.
✗ Incorrect
We select records with timestamp < cutoff_date to archive old data.
4fill in blank
hardFill both blanks to filter and store only valid historical data.
SCADA systems
valid_data = {record: record[1]2 for record in data if record.status [2] 'valid'} Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using != instead of == for filtering valid records.
✗ Incorrect
We square the record value with **2 and filter records where status is valid using ==.
5fill in blank
hardFill all three blanks to create a summary dictionary of historical data counts.
SCADA systems
summary = [1]: len(records) for [2], records in grouped_data.items() if [3] > 0}
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'count' instead of 'len(records)' for filtering.
✗ Incorrect
We use category as the key, iterate over category and records, and filter where the length of records is greater than zero.