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 < 200 OR motion) { porch lamp ON } else { porch lamp OFF }
The light reading is 310 and motion is not detected (false). What happens? (a) porch lamp OFF (b) porch lamp ON -
2.🤖 if (temperature > 30) { show “Hot” } else if (temperature > 21) { show “Warm” } else { show “Cool” }
The temperature is 28 °C. What is shown? (a) Cool (b) Hot (c) Warm - 3.🤖 “if (A AND B)” is true when … (a) only A is true (b) only B is true (c) both are false (d) both A and B are true
-
4.🤖 if (light < 300 OR motion) { porch lamp ON } else { porch lamp OFF }
The light reading is 490 and motion is not detected (false). What happens? (a) porch lamp OFF (b) porch lamp ON -
5.🤖 if (distance < 20) { buzzer beeps } else { buzzer is silent }
The distance sensor reads 21 cm. What happens? (a) buzzer is silent (b) buzzer beeps -
6.🤖 if (temperature > 25) { fan ON } else { fan OFF }
The temperature sensor reads 21 °C. What happens? (a) fan OFF (b) fan ON -
7.🤖 if (light < 200 OR motion) { porch lamp ON } else { porch lamp OFF }
The light reading is 150 and motion is detected (true). What happens? (a) porch lamp OFF (b) porch lamp ON -
8.🤖 if (light < 400 OR motion) { porch lamp ON } else { porch lamp OFF }
The light reading is 490 and motion is not detected (false). What happens? (a) porch lamp OFF (b) porch lamp ON -
9.🤖 if (temperature > 33) { show “Hot” } else if (temperature > 22) { show “Warm” } else { show “Cool” }
The temperature is 14 °C. What is shown? (a) Cool (b) Warm (c) Hot - 10.🤖 In “if (temp > 30)”, what runs when temp is exactly 30? (a) the if part (b) both parts (c) neither part (d) the else part
-
11.🤖 if (temperature > 28) { fan ON } else { fan OFF }
The temperature sensor reads 26 °C. What happens? (a) fan ON (b) fan OFF -
12.🤖 if (light < 300 OR motion) { porch lamp ON } else { porch lamp OFF }
The light reading is 280 and motion is not detected (false). What happens? (a) porch lamp OFF (b) porch lamp ON -
13.🤖 if (light < 300 OR motion) { porch lamp ON } else { porch lamp OFF }
The light reading is 230 and motion is not detected (false). What happens? (a) porch lamp ON (b) porch lamp OFF -
14.🤖 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 ON (b) porch lamp OFF -
15.🤖 if (temperature > 38) { show “Hot” } else if (temperature > 26) { show “Warm” } else { show “Cool” }
The temperature is 37 °C. What is shown? (a) Cool (b) Warm (c) Hot -
16.🤖 if (distance < 30) { buzzer beeps } else { buzzer is silent }
The distance sensor reads 31 cm. What happens? (a) buzzer beeps (b) buzzer is silent -
17.🤖 if (light < 200 AND motion) { porch lamp ON } else { porch lamp OFF }
The light reading is 180 and motion is not detected (false). What happens? (a) porch lamp ON (b) porch lamp OFF -
18.🤖 if (light < 400) { lamp ON } else { lamp OFF }
The light sensor reads 280. What happens? (a) lamp OFF (b) lamp ON -
19.🤖 if (light < 300) { lamp ON } else { lamp OFF }
The light sensor reads 290. What happens? (a) lamp OFF (b) lamp ON -
20.🤖 if (light < 300 AND motion) { porch lamp ON } else { porch lamp OFF }
The light reading is 200 and motion is detected (true). What happens? (a) porch lamp OFF (b) porch lamp ON -
21.🤖 if (light < 400 AND motion) { porch lamp ON } else { porch lamp OFF }
The light reading is 570 and motion is detected (true). What happens? (a) porch lamp OFF (b) porch lamp ON -
22.🤖 if (light < 200 AND motion) { porch lamp ON } else { porch lamp OFF }
The light reading is 410 and motion is not detected (false). What happens? (a) porch lamp ON (b) porch lamp OFF -
23.🤖 if (light < 200 OR motion) { porch lamp ON } else { porch lamp OFF }
The light reading is 190 and motion is detected (true). What happens? (a) porch lamp OFF (b) porch lamp ON -
24.🤖 if (temperature > 28) { fan ON } else { fan OFF }
The temperature sensor reads 20 °C. What happens? (a) fan OFF (b) fan ON -
25.🤖 if (sound > 60) { red LED ON } else { green LED ON }
The sound sensor reads 41. What happens? (a) green LED ON (b) red LED ON -
26.🤖 if (temperature > 36) { show “Hot” } else if (temperature > 26) { show “Warm” } else { show “Cool” }
The temperature is 23 °C. What is shown? (a) Warm (b) Hot (c) Cool -
27.🤖 if (light < 200 OR motion) { porch lamp ON } else { porch lamp OFF }
The light reading is 620 and motion is detected (true). What happens? (a) porch lamp OFF (b) porch lamp ON -
28.🤖 if (light < 400 AND motion) { porch lamp ON } else { porch lamp OFF }
The light reading is 440 and motion is detected (true). What happens? (a) porch lamp ON (b) porch lamp OFF -
29.🤖 if (distance < 10) { buzzer beeps } else { buzzer is silent }
The distance sensor reads 6 cm. What happens? (a) buzzer beeps (b) buzzer is silent -
30.🤖 if (sound > 70) { red LED ON } else { green LED ON }
The sound sensor reads 64. What happens? (a) green LED ON (b) red LED ON -
31.🤖 if (light < 400 AND motion) { porch lamp ON } else { porch lamp OFF }
The light reading is 250 and motion is not detected (false). What happens? (a) porch lamp OFF (b) porch lamp ON -
32.🤖 if (light < 200 AND motion) { porch lamp ON } else { porch lamp OFF }
The light reading is 380 and motion is detected (true). What happens? (a) porch lamp OFF (b) porch lamp ON -
33.🤖 if (temperature > 30) { fan ON } else { fan OFF }
The temperature sensor reads 30 °C. What happens? (a) fan OFF (b) fan ON -
34.🤖 if (light < 300 AND motion) { porch lamp ON } else { porch lamp OFF }
The light reading is 70 and motion is detected (true). What happens? (a) porch lamp ON (b) porch lamp OFF -
35.🤖 if (sound > 80) { red LED ON } else { green LED ON }
The sound sensor reads 60. What happens? (a) red LED ON (b) green LED ON -
36.🤖 if (temperature > 30) { fan ON } else { fan OFF }
The temperature sensor reads 23 °C. What happens? (a) fan ON (b) fan OFF -
37.🤖 if (light < 400 AND motion) { porch lamp ON } else { porch lamp OFF }
The light reading is 500 and motion is detected (true). What happens? (a) porch lamp OFF (b) porch lamp ON -
38.🤖 if (sound > 60) { red LED ON } else { green LED ON }
The sound sensor reads 58. What happens? (a) green LED ON (b) red LED ON -
39.🤖 if (light < 200 AND motion) { porch lamp ON } else { porch lamp OFF }
The light reading is 330 and motion is detected (true). What happens? (a) porch lamp OFF (b) porch lamp ON -
40.🤖 if (light < 200 OR motion) { porch lamp ON } else { porch lamp OFF }
The light reading is 480 and motion is detected (true). What happens? (a) porch lamp OFF (b) porch lamp ON
Answer key
- porch lamp OFF
- Warm
- both A and B are true
- porch lamp OFF
- buzzer is silent
- fan OFF
- porch lamp ON
- porch lamp OFF
- Cool
- the else part
- fan OFF
- porch lamp ON
- porch lamp ON
- porch lamp OFF
- Warm
- buzzer is silent
- porch lamp OFF
- lamp ON
- lamp ON
- porch lamp ON
- porch lamp OFF
- porch lamp OFF
- porch lamp ON
- fan OFF
- green LED ON
- Cool
- porch lamp ON
- porch lamp OFF
- buzzer beeps
- green LED ON
- porch lamp OFF
- porch lamp OFF
- fan OFF
- porch lamp ON
- green LED ON
- fan OFF
- porch lamp OFF
- green LED ON
- porch lamp OFF
- porch lamp ON
Free electronics lessons, practice and worksheets at talentjr.in/electronics-for-kids