Electronics Worksheet: If Else with Sensors
Remember (Test, then choose): Put the reading into the condition: true → the if part, false → the else part. > means strictly more and < strictly less; an equal reading makes them false. AND: both true. OR: at least one true. In a chain, the first true condition wins.
NameDateTime takenScore ___ / 40
-
1.🤖 if (light < 400 OR motion) { porch lamp ON } else { porch lamp OFF }
The light reading is 140 and motion is detected (true). What happens? (a) porch lamp ON (b) porch lamp OFF -
2.🤖 if (temperature > 28) { fan ON } else { fan OFF }
The temperature sensor reads 33 °C. What happens? (a) fan ON (b) fan OFF -
3.🤖 if (temperature > 32) { show “Hot” } else if (temperature > 22) { show “Warm” } else { show “Cool” }
The temperature is 40 °C. What is shown? (a) Warm (b) Cool (c) Hot -
4.🤖 if (temperature > 30) { show “Hot” } else if (temperature > 19) { show “Warm” } else { show “Cool” }
The temperature is 26 °C. What is shown? (a) Warm (b) Hot (c) Cool -
5.🤖 if (light < 200 AND motion) { porch lamp ON } else { porch lamp OFF }
The light reading is 350 and motion is not detected (false). What happens? (a) porch lamp ON (b) porch lamp OFF -
6.🤖 if (temperature > 36) { show “Hot” } else if (temperature > 20) { show “Warm” } else { show “Cool” }
The temperature is 32 °C. What is shown? (a) Warm (b) Cool (c) Hot -
7.🤖 if (temperature > 28) { fan ON } else { fan OFF }
The temperature sensor reads 27 °C. What happens? (a) fan ON (b) fan OFF -
8.🤖 if (distance < 30) { buzzer beeps } else { buzzer is silent }
The distance sensor reads 32 cm. What happens? (a) buzzer beeps (b) buzzer is silent -
9.🤖 if (light < 200) { lamp ON } else { lamp OFF }
The light sensor reads 113. What happens? (a) lamp ON (b) lamp OFF -
10.🤖 if (temperature > 28) { fan ON } else { fan OFF }
The temperature sensor reads 29 °C. What happens? (a) fan ON (b) fan OFF -
11.🤖 if (distance < 20) { buzzer beeps } else { buzzer is silent }
The distance sensor reads 22 cm. What happens? (a) buzzer is silent (b) buzzer beeps -
12.🤖 if (temperature > 38) { show “Hot” } else if (temperature > 20) { show “Warm” } else { show “Cool” }
The temperature is 19 °C. What is shown? (a) Warm (b) Hot (c) Cool - 13.🤖 “if (A AND B)” is true when … (a) both are false (b) only A is true (c) only B is true (d) both A and B are true
-
14.🤖 if (temperature > 32) { show “Hot” } else if (temperature > 25) { show “Warm” } else { show “Cool” }
The temperature is 24 °C. What is shown? (a) Hot (b) Cool (c) Warm -
15.🤖 if (light < 300 OR motion) { porch lamp ON } else { porch lamp OFF }
The light reading is 130 and motion is not detected (false). What happens? (a) porch lamp ON (b) porch lamp OFF - 16.🤖 In “if (temp > 30)”, what runs when temp is exactly 30? (a) the if part (b) the else part (c) neither part (d) both parts
-
17.🤖 if (light < 400 AND motion) { porch lamp ON } else { porch lamp OFF }
The light reading is 630 and motion is not detected (false). What happens? (a) porch lamp OFF (b) porch lamp ON -
18.🤖 if (distance < 15) { buzzer beeps } else { buzzer is silent }
The distance sensor reads 11 cm. What happens? (a) buzzer beeps (b) buzzer is silent -
19.🤖 if (light < 400 OR motion) { porch lamp ON } else { porch lamp OFF }
The light reading is 100 and motion is not detected (false). What happens? (a) porch lamp ON (b) porch lamp OFF -
20.🤖 if (light < 400 OR motion) { porch lamp ON } else { porch lamp OFF }
The light reading is 350 and motion is detected (true). What happens? (a) porch lamp ON (b) porch lamp OFF -
21.🤖 if (temperature > 32) { show “Hot” } else if (temperature > 22) { show “Warm” } else { show “Cool” }
The temperature is 27 °C. What is shown? (a) Warm (b) Cool (c) Hot -
22.🤖 if (temperature > 32) { fan ON } else { fan OFF }
The temperature sensor reads 32 °C. What happens? (a) fan ON (b) fan OFF -
23.🤖 if (light < 200 AND motion) { porch lamp ON } else { porch lamp OFF }
The light reading is 470 and motion is not detected (false). What happens? (a) porch lamp OFF (b) porch lamp ON -
24.🤖 if (light < 200 AND motion) { porch lamp ON } else { porch lamp OFF }
The light reading is 220 and motion is not detected (false). What happens? (a) porch lamp ON (b) porch lamp OFF -
25.🤖 if (light < 300 OR motion) { porch lamp ON } else { porch lamp OFF }
The light reading is 390 and motion is not detected (false). What happens? (a) porch lamp ON (b) porch lamp OFF -
26.🤖 if (temperature > 38) { show “Hot” } else if (temperature > 21) { show “Warm” } else { show “Cool” }
The temperature is 16 °C. What is shown? (a) Warm (b) Hot (c) Cool -
27.🤖 if (temperature > 36) { show “Hot” } else if (temperature > 18) { show “Warm” } else { show “Cool” }
The temperature is 16 °C. What is shown? (a) Cool (b) Hot (c) Warm -
28.🤖 if (light < 200 OR motion) { porch lamp ON } else { porch lamp OFF }
The light reading is 510 and motion is not detected (false). What happens? (a) porch lamp ON (b) porch lamp OFF -
29.🤖 if (light < 200) { lamp ON } else { lamp OFF }
The light sensor reads 215. What happens? (a) lamp ON (b) lamp OFF -
30.🤖 if (moisture < 50) { pump ON } else { pump OFF }
The soil moisture sensor reads 68 %. What happens? (a) pump ON (b) pump OFF -
31.🤖 if (light < 200 AND motion) { porch lamp ON } else { porch lamp OFF }
The light reading is 230 and motion is not detected (false). What happens? (a) porch lamp OFF (b) porch lamp ON -
32.🤖 if (moisture < 30) { pump ON } else { pump OFF }
The soil moisture sensor reads 42 %. What happens? (a) pump OFF (b) pump ON -
33.🤖 if (temperature > 33) { show “Hot” } else if (temperature > 20) { show “Warm” } else { show “Cool” }
The temperature is 15 °C. What is shown? (a) Cool (b) Warm (c) Hot -
34.🤖 if (temperature > 31) { show “Hot” } else if (temperature > 22) { show “Warm” } else { show “Cool” }
The temperature is 16 °C. What is shown? (a) Hot (b) Cool (c) Warm -
35.🤖 if (moisture < 40) { pump ON } else { pump OFF }
The soil moisture sensor reads 51 %. What happens? (a) pump ON (b) pump OFF -
36.🤖 if (distance < 15) { buzzer beeps } else { buzzer is silent }
The distance sensor reads 15 cm. What happens? (a) buzzer beeps (b) buzzer is silent -
37.🤖 if (light < 200 OR motion) { porch lamp ON } else { porch lamp OFF }
The light reading is 100 and motion is detected (true). What happens? (a) porch lamp OFF (b) porch lamp ON -
38.🤖 if (light < 400 AND motion) { porch lamp ON } else { porch lamp OFF }
The light reading is 120 and motion is detected (true). What happens? (a) porch lamp OFF (b) porch lamp ON -
39.🤖 if (moisture < 30) { pump ON } else { pump OFF }
The soil moisture sensor reads 26 %. What happens? (a) pump ON (b) pump OFF -
40.🤖 if (temperature > 30) { show “Hot” } else if (temperature > 18) { show “Warm” } else { show “Cool” }
The temperature is 23 °C. What is shown? (a) Hot (b) Warm (c) Cool
Answer key
- porch lamp ON
- fan ON
- Hot
- Warm
- porch lamp OFF
- Warm
- fan OFF
- buzzer is silent
- lamp ON
- fan ON
- buzzer is silent
- Cool
- both A and B are true
- Cool
- porch lamp ON
- the else part
- porch lamp OFF
- buzzer beeps
- porch lamp ON
- porch lamp ON
- Warm
- fan OFF
- porch lamp OFF
- porch lamp OFF
- porch lamp OFF
- Cool
- Cool
- porch lamp OFF
- lamp OFF
- pump OFF
- porch lamp OFF
- pump OFF
- Cool
- Cool
- pump OFF
- buzzer is silent
- porch lamp ON
- porch lamp ON
- pump ON
- Warm
Free electronics lessons, practice and worksheets at talentjr.in/electronics-for-kids