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