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