Complete the code to read the temperature sensor value.
temperature = sensor.read_temperature([1])The sensor.read_temperature function requires the unit of measurement. Using 'Celsius' returns the temperature in degrees Celsius.
Complete the code to trigger a cooling fan when temperature exceeds threshold.
if temperature [1] threshold: fan.turn_on()
The fan should turn on when the temperature is greater than the threshold to cool the system.
Fix the error in the code to log temperature readings every 5 seconds.
while True: log.write(temperature) time.sleep([1])
To log every 5 seconds, the sleep duration must be 5 seconds.
Fill both blanks to create a dictionary of sensor names and their temperature values above threshold.
high_temps = {sensor[1]: temp for sensor, temp in readings.items() if temp [2] threshold }Use sensor.name to get the sensor's name and filter temperatures greater than the threshold.
Fill all three blanks to create a filtered dictionary with uppercase sensor names and temperatures below threshold.
filtered = { [1]: [2] for sensor, temp in data.items() if temp [3] threshold }Use sensor.name.upper() for uppercase keys, temp as values, and filter temps less than threshold.