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 600 and motion is detected (true). What happens? (a) porch lamp OFF (b) porch lamp ON -
2.🤖 if (moisture < 40) { pump ON } else { pump OFF }
The soil moisture sensor reads 23 %. What happens? (a) pump ON (b) pump OFF -
3.🤖 if (light < 400) { lamp ON } else { lamp OFF }
The light sensor reads 499. What happens? (a) lamp ON (b) lamp OFF -
4.🤖 if (light < 200 AND motion) { porch lamp ON } else { porch lamp OFF }
The light reading is 650 and motion is detected (true). What happens? (a) porch lamp ON (b) porch lamp OFF - 5.🤖 In “if (temp > 30)”, what runs when temp is exactly 30? (a) both parts (b) neither part (c) the else part (d) the if part
-
6.🤖 if (temperature > 31) { show “Hot” } else if (temperature > 22) { show “Warm” } else { show “Cool” }
The temperature is 41 °C. What is shown? (a) Hot (b) Warm (c) Cool -
7.🤖 if (light < 200 AND motion) { porch lamp ON } else { porch lamp OFF }
The light reading is 570 and motion is not detected (false). What happens? (a) porch lamp OFF (b) porch lamp ON -
8.🤖 if (light < 400) { lamp ON } else { lamp OFF }
The light sensor reads 492. What happens? (a) lamp ON (b) lamp OFF -
9.🤖 if (light < 400 OR motion) { porch lamp ON } else { porch lamp OFF }
The light reading is 120 and motion is not detected (false). What happens? (a) porch lamp ON (b) porch lamp OFF -
10.🤖 if (sound > 80) { red LED ON } else { green LED ON }
The sound sensor reads 73. What happens? (a) red LED ON (b) green LED ON -
11.🤖 if (light < 200 AND motion) { porch lamp ON } else { porch lamp OFF }
The light reading is 460 and motion is detected (true). What happens? (a) porch lamp OFF (b) porch lamp ON -
12.🤖 if (temperature > 31) { show “Hot” } else if (temperature > 21) { show “Warm” } else { show “Cool” }
The temperature is 43 °C. What is shown? (a) Hot (b) Cool (c) Warm -
13.🤖 if (distance < 15) { buzzer beeps } else { buzzer is silent }
The distance sensor reads 8 cm. What happens? (a) buzzer beeps (b) buzzer is silent -
14.🤖 if (light < 300 AND motion) { porch lamp ON } else { porch lamp OFF }
The light reading is 570 and motion is detected (true). What happens? (a) porch lamp ON (b) porch lamp OFF -
15.🤖 if (temperature > 37) { show “Hot” } else if (temperature > 24) { show “Warm” } else { show “Cool” }
The temperature is 14 °C. What is shown? (a) Hot (b) Warm (c) Cool -
16.🤖 if (light < 400) { lamp ON } else { lamp OFF }
The light sensor reads 282. What happens? (a) lamp OFF (b) lamp ON - 17.🤖 “if (A AND B)” is true when … (a) only A is true (b) both are false (c) both A and B are true (d) only B is true
-
18.🤖 if (temperature > 36) { show “Hot” } else if (temperature > 24) { show “Warm” } else { show “Cool” }
The temperature is 19 °C. What is shown? (a) Warm (b) Hot (c) Cool -
19.🤖 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 -
20.🤖 if (light < 400 OR motion) { porch lamp ON } else { porch lamp OFF }
The light reading is 140 and motion is not detected (false). What happens? (a) porch lamp OFF (b) porch lamp ON -
21.🤖 if (temperature > 37) { show “Hot” } else if (temperature > 21) { show “Warm” } else { show “Cool” }
The temperature is 12 °C. What is shown? (a) Hot (b) Cool (c) Warm -
22.🤖 if (temperature > 33) { show “Hot” } else if (temperature > 24) { show “Warm” } else { show “Cool” }
The temperature is 18 °C. What is shown? (a) Hot (b) Cool (c) Warm -
23.🤖 if (moisture < 30) { pump ON } else { pump OFF }
The soil moisture sensor reads 18 %. What happens? (a) pump ON (b) pump OFF -
24.🤖 if (temperature > 33) { show “Hot” } else if (temperature > 26) { show “Warm” } else { show “Cool” }
The temperature is 15 °C. What is shown? (a) Hot (b) Cool (c) Warm -
25.🤖 if (light < 200) { lamp ON } else { lamp OFF }
The light sensor reads 99. What happens? (a) lamp ON (b) lamp OFF -
26.🤖 if (light < 300 OR motion) { porch lamp ON } else { porch lamp OFF }
The light reading is 70 and motion is not detected (false). What happens? (a) porch lamp OFF (b) porch lamp ON -
27.🤖 if (light < 400 AND motion) { porch lamp ON } else { porch lamp OFF }
The light reading is 370 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 130 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 125. What happens? (a) lamp ON (b) lamp OFF -
30.🤖 if (light < 400 OR motion) { porch lamp ON } else { porch lamp OFF }
The light reading is 430 and motion is not detected (false). What happens? (a) porch lamp OFF (b) porch lamp ON -
31.🤖 if (temperature > 38) { show “Hot” } else if (temperature > 22) { show “Warm” } else { show “Cool” }
The temperature is 27 °C. What is shown? (a) Cool (b) Hot (c) Warm -
32.🤖 if (light < 200) { lamp ON } else { lamp OFF }
The light sensor reads 219. What happens? (a) lamp ON (b) lamp OFF -
33.🤖 if (moisture < 40) { pump ON } else { pump OFF }
The soil moisture sensor reads 52 %. What happens? (a) pump ON (b) pump OFF -
34.🤖 if (light < 400 OR 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 -
35.🤖 if (temperature > 31) { show “Hot” } else if (temperature > 19) { show “Warm” } else { show “Cool” }
The temperature is 42 °C. What is shown? (a) Hot (b) Warm (c) Cool -
36.🤖 if (temperature > 37) { show “Hot” } else if (temperature > 21) { show “Warm” } else { show “Cool” }
The temperature is 29 °C. What is shown? (a) Hot (b) Cool (c) Warm -
37.🤖 if (temperature > 31) { show “Hot” } else if (temperature > 20) { show “Warm” } else { show “Cool” }
The temperature is 27 °C. What is shown? (a) Hot (b) Warm (c) Cool -
38.🤖 if (light < 300 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 -
39.🤖 if (light < 200 AND 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 -
40.🤖 if (light < 200 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
Answer key
- porch lamp ON
- pump ON
- lamp OFF
- porch lamp OFF
- the else part
- Hot
- porch lamp OFF
- lamp OFF
- porch lamp ON
- green LED ON
- porch lamp OFF
- Hot
- buzzer beeps
- porch lamp OFF
- Cool
- lamp ON
- both A and B are true
- Cool
- porch lamp OFF
- porch lamp ON
- Cool
- Cool
- pump ON
- Cool
- lamp ON
- porch lamp ON
- porch lamp OFF
- porch lamp ON
- lamp ON
- porch lamp OFF
- Warm
- lamp OFF
- pump OFF
- porch lamp ON
- Hot
- Warm
- Warm
- porch lamp OFF
- porch lamp ON
- porch lamp OFF
Free electronics lessons, practice and worksheets at talentjr.in/electronics-for-kids