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.🤖 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
- 2.🤖 “if (A AND B)” is true when … (a) both are false (b) both A and B are true (c) only A is true (d) only B is true
-
3.🤖 if (light < 200 OR motion) { porch lamp ON } else { porch lamp OFF }
The light reading is 190 and motion is not detected (false). What happens? (a) porch lamp OFF (b) porch lamp ON -
4.🤖 if (light < 500) { lamp ON } else { lamp OFF }
The light sensor reads 537. What happens? (a) lamp ON (b) lamp OFF -
5.🤖 if (light < 300) { lamp ON } else { lamp OFF }
The light sensor reads 276. What happens? (a) lamp ON (b) lamp OFF -
6.🤖 if (light < 300) { lamp ON } else { lamp OFF }
The light sensor reads 339. What happens? (a) lamp OFF (b) lamp ON -
7.🤖 if (sound > 60) { red LED ON } else { green LED ON }
The sound sensor reads 71. What happens? (a) green LED ON (b) red LED ON -
8.🤖 if (light < 300 OR motion) { porch lamp ON } else { porch lamp OFF }
The light reading is 580 and motion is not detected (false). What happens? (a) porch lamp OFF (b) porch lamp ON -
9.🤖 if (light < 200 OR motion) { porch lamp ON } else { porch lamp OFF }
The light reading is 420 and motion is detected (true). What happens? (a) porch lamp OFF (b) porch lamp ON -
10.🤖 if (light < 300 AND motion) { porch lamp ON } else { porch lamp OFF }
The light reading is 120 and motion is detected (true). What happens? (a) porch lamp ON (b) porch lamp OFF -
11.🤖 if (light < 300 AND motion) { porch lamp ON } else { porch lamp OFF }
The light reading is 410 and motion is detected (true). What happens? (a) porch lamp OFF (b) porch lamp ON -
12.🤖 if (light < 300 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 -
13.🤖 if (light < 400 OR motion) { porch lamp ON } else { porch lamp OFF }
The light reading is 90 and motion is detected (true). What happens? (a) porch lamp OFF (b) porch lamp ON -
14.🤖 if (light < 200 AND motion) { porch lamp ON } else { porch lamp OFF }
The light reading is 420 and motion is detected (true). What happens? (a) porch lamp ON (b) porch lamp OFF -
15.🤖 if (light < 400 OR motion) { porch lamp ON } else { porch lamp OFF }
The light reading is 190 and motion is not detected (false). What happens? (a) porch lamp ON (b) porch lamp OFF -
16.🤖 if (temperature > 36) { show “Hot” } else if (temperature > 23) { show “Warm” } else { show “Cool” }
The temperature is 41 °C. What is shown? (a) Cool (b) Warm (c) Hot -
17.🤖 if (temperature > 36) { show “Hot” } else if (temperature > 19) { show “Warm” } else { show “Cool” }
The temperature is 17 °C. What is shown? (a) Cool (b) Warm (c) Hot -
18.🤖 if (temperature > 33) { show “Hot” } else if (temperature > 25) { show “Warm” } else { show “Cool” }
The temperature is 23 °C. What is shown? (a) Warm (b) Cool (c) Hot -
19.🤖 if (temperature > 37) { show “Hot” } else if (temperature > 24) { show “Warm” } else { show “Cool” }
The temperature is 41 °C. What is shown? (a) Warm (b) Hot (c) Cool -
20.🤖 if (moisture < 30) { pump ON } else { pump OFF }
The soil moisture sensor reads 16 %. What happens? (a) pump OFF (b) pump ON -
21.🤖 if (light < 400 AND 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 -
22.🤖 if (temperature > 35) { show “Hot” } else if (temperature > 22) { show “Warm” } else { show “Cool” }
The temperature is 21 °C. What is shown? (a) Cool (b) Warm (c) Hot -
23.🤖 if (light < 500) { lamp ON } else { lamp OFF }
The light sensor reads 538. What happens? (a) lamp OFF (b) lamp ON -
24.🤖 if (temperature > 34) { show “Hot” } else if (temperature > 25) { show “Warm” } else { show “Cool” }
The temperature is 39 °C. What is shown? (a) Warm (b) Cool (c) Hot -
25.🤖 if (light < 300 OR motion) { porch lamp ON } else { porch lamp OFF }
The light reading is 520 and motion is not detected (false). What happens? (a) porch lamp OFF (b) porch lamp ON -
26.🤖 if (light < 400 AND 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 (temperature > 35) { show “Hot” } else if (temperature > 21) { show “Warm” } else { show “Cool” }
The temperature is 35 °C. What is shown? (a) Warm (b) Cool (c) Hot -
28.🤖 if (light < 200 OR motion) { porch lamp ON } else { porch lamp OFF }
The light reading is 530 and motion is not detected (false). What happens? (a) porch lamp OFF (b) porch lamp ON -
29.🤖 if (temperature > 37) { show “Hot” } else if (temperature > 18) { show “Warm” } else { show “Cool” }
The temperature is 32 °C. What is shown? (a) Warm (b) Hot (c) Cool -
30.🤖 if (light < 400) { lamp ON } else { lamp OFF }
The light sensor reads 309. What happens? (a) lamp OFF (b) lamp ON -
31.🤖 if (distance < 30) { buzzer beeps } else { buzzer is silent }
The distance sensor reads 39 cm. What happens? (a) buzzer beeps (b) buzzer is silent -
32.🤖 if (light < 400) { lamp ON } else { lamp OFF }
The light sensor reads 447. What happens? (a) lamp OFF (b) lamp ON -
33.🤖 if (temperature > 33) { show “Hot” } else if (temperature > 19) { show “Warm” } else { show “Cool” }
The temperature is 36 °C. What is shown? (a) Cool (b) Warm (c) Hot -
34.🤖 if (light < 200 AND motion) { porch lamp ON } else { porch lamp OFF }
The light reading is 510 and motion is detected (true). What happens? (a) porch lamp OFF (b) porch lamp ON -
35.🤖 if (temperature > 30) { show “Hot” } else if (temperature > 19) { show “Warm” } else { show “Cool” }
The temperature is 26 °C. What is shown? (a) Hot (b) Cool (c) Warm -
36.🤖 if (light < 400 OR motion) { porch lamp ON } else { porch lamp OFF }
The light reading is 640 and motion is detected (true). What happens? (a) porch lamp ON (b) porch lamp OFF -
37.🤖 if (temperature > 37) { show “Hot” } else if (temperature > 19) { show “Warm” } else { show “Cool” }
The temperature is 39 °C. What is shown? (a) Warm (b) Cool (c) Hot -
38.🤖 if (sound > 60) { red LED ON } else { green LED ON }
The sound sensor reads 66. What happens? (a) red LED ON (b) green LED ON -
39.🤖 if (light < 200 OR motion) { porch lamp ON } else { porch lamp OFF }
The light reading is 580 and motion is detected (true). What happens? (a) porch lamp OFF (b) porch lamp ON -
40.🤖 if (moisture < 30) { pump ON } else { pump OFF }
The soil moisture sensor reads 24 %. What happens? (a) pump OFF (b) pump ON
Answer key
- the else part
- both A and B are true
- porch lamp ON
- lamp OFF
- lamp ON
- lamp OFF
- red LED ON
- porch lamp OFF
- porch lamp ON
- porch lamp ON
- porch lamp OFF
- porch lamp ON
- porch lamp ON
- porch lamp OFF
- porch lamp ON
- Hot
- Cool
- Cool
- Hot
- pump ON
- porch lamp OFF
- Cool
- lamp OFF
- Hot
- porch lamp OFF
- porch lamp OFF
- Warm
- porch lamp OFF
- Warm
- lamp ON
- buzzer is silent
- lamp OFF
- Hot
- porch lamp OFF
- Warm
- porch lamp ON
- Hot
- red LED ON
- porch lamp ON
- pump ON
Free electronics lessons, practice and worksheets at talentjr.in/electronics-for-kids