Complete the code to turn the cooling fan ON when the temperature exceeds 50°C.
if temperature [1] 50: fan_state = 'ON'
The cooling fan should turn ON when the temperature is greater than 50°C, so the correct operator is >.
Complete the code to set the fan speed to 100% when the temperature is above 60°C.
fan_speed = 100 if temperature [1] 60 else 0
The fan speed should be 100% when temperature is greater than 60°C, so the operator > is correct.
Fix the error in the code to correctly turn the fan OFF when temperature is below 40°C.
if temperature [1] 40: fan_state = 'OFF'
The fan should turn OFF when temperature is less than 40°C, so the operator < is correct.
Fill both blanks to create a dictionary comprehension that sets fan speed to 100 if temperature is above 55, else 0.
fan_speeds = {room: 100 if temp [1] 55 else [2] for room, temp in temps.items()}The fan speed is 100 if temperature is greater than 55, else 0. So the first blank is > and the second blank is 0.
Fill all three blanks to create a dictionary comprehension that sets fan speed to 100 if temperature is above 60, else 50 if above 40, else 0.
fan_speeds = {room: 100 if temp [1] 60 else 50 if temp [2] 40 else [3] for room, temp in temps.items()}The first condition checks if temp > 60, the second if temp > 40, else 0. So blanks are >, >, and 0.