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 370 and motion is detected (true). What happens? (a) porch lamp OFF (b) porch lamp ON -
2.🤖 if (light < 400 OR motion) { porch lamp ON } else { porch lamp OFF }
The light reading is 300 and motion is not detected (false). What happens? (a) porch lamp OFF (b) porch lamp ON - 3.🤖 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
-
4.🤖 if (distance < 30) { buzzer beeps } else { buzzer is silent }
The distance sensor reads 35 cm. What happens? (a) buzzer is silent (b) buzzer beeps -
5.🤖 if (distance < 20) { buzzer beeps } else { buzzer is silent }
The distance sensor reads 28 cm. What happens? (a) buzzer beeps (b) buzzer is silent -
6.🤖 if (light < 400 OR motion) { porch lamp ON } else { porch lamp OFF }
The light reading is 150 and motion is not detected (false). What happens? (a) porch lamp ON (b) porch lamp OFF -
7.🤖 if (temperature > 36) { show “Hot” } else if (temperature > 24) { show “Warm” } else { show “Cool” }
The temperature is 10 °C. What is shown? (a) Warm (b) Cool (c) Hot -
8.🤖 if (temperature > 33) { show “Hot” } else if (temperature > 21) { show “Warm” } else { show “Cool” }
The temperature is 28 °C. What is shown? (a) Warm (b) Cool (c) Hot -
9.🤖 if (distance < 30) { buzzer beeps } else { buzzer is silent }
The distance sensor reads 32 cm. What happens? (a) buzzer is silent (b) buzzer beeps -
10.🤖 if (light < 200 OR motion) { porch lamp ON } else { porch lamp OFF }
The light reading is 500 and motion is not detected (false). What happens? (a) porch lamp ON (b) porch lamp OFF -
11.🤖 if (temperature > 32) { show “Hot” } else if (temperature > 21) { show “Warm” } else { show “Cool” }
The temperature is 33 °C. What is shown? (a) Cool (b) Hot (c) Warm -
12.🤖 if (temperature > 37) { show “Hot” } else if (temperature > 21) { show “Warm” } else { show “Cool” }
The temperature is 21 °C. What is shown? (a) Cool (b) Hot (c) Warm -
13.🤖 if (light < 200 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 -
14.🤖 if (light < 400) { lamp ON } else { lamp OFF }
The light sensor reads 535. What happens? (a) lamp OFF (b) lamp ON -
15.🤖 if (light < 200 OR motion) { porch lamp ON } else { porch lamp OFF }
The light reading is 170 and motion is detected (true). What happens? (a) porch lamp OFF (b) porch lamp ON -
16.🤖 if (light < 400 OR motion) { porch lamp ON } else { porch lamp OFF }
The light reading is 50 and motion is not detected (false). What happens? (a) porch lamp OFF (b) porch lamp ON -
17.🤖 if (light < 200 AND 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 -
18.🤖 if (moisture < 30) { pump ON } else { pump OFF }
The soil moisture sensor reads 29 %. What happens? (a) pump OFF (b) pump ON -
19.🤖 if (light < 300 AND motion) { porch lamp ON } else { porch lamp OFF }
The light reading is 170 and motion is detected (true). What happens? (a) porch lamp OFF (b) porch lamp ON -
20.🤖 if (temperature > 38) { show “Hot” } else if (temperature > 25) { show “Warm” } else { show “Cool” }
The temperature is 43 °C. What is shown? (a) Cool (b) Warm (c) Hot - 21.🤖 “if (A AND B)” is true when … (a) only B is true (b) both are false (c) only A is true (d) both A and B are true
-
22.🤖 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 -
23.🤖 if (light < 200 OR motion) { porch lamp ON } else { porch lamp OFF }
The light reading is 100 and motion is detected (true). What happens? (a) porch lamp ON (b) porch lamp OFF -
24.🤖 if (light < 200) { lamp ON } else { lamp OFF }
The light sensor reads 102. What happens? (a) lamp OFF (b) lamp ON -
25.🤖 if (temperature > 38) { show “Hot” } else if (temperature > 25) { show “Warm” } else { show “Cool” }
The temperature is 35 °C. What is shown? (a) Hot (b) Warm (c) Cool -
26.🤖 if (light < 500) { lamp ON } else { lamp OFF }
The light sensor reads 420. What happens? (a) lamp OFF (b) lamp ON -
27.🤖 if (light < 200) { lamp ON } else { lamp OFF }
The light sensor reads 295. What happens? (a) lamp ON (b) lamp OFF -
28.🤖 if (light < 200) { lamp ON } else { lamp OFF }
The light sensor reads 210. What happens? (a) lamp OFF (b) lamp ON -
29.🤖 if (temperature > 38) { show “Hot” } else if (temperature > 21) { show “Warm” } else { show “Cool” }
The temperature is 45 °C. What is shown? (a) Cool (b) Hot (c) Warm -
30.🤖 if (temperature > 33) { show “Hot” } else if (temperature > 21) { show “Warm” } else { show “Cool” }
The temperature is 27 °C. What is shown? (a) Cool (b) Hot (c) Warm -
31.🤖 if (sound > 70) { red LED ON } else { green LED ON }
The sound sensor reads 88. What happens? (a) green LED ON (b) red LED ON -
32.🤖 if (light < 300 OR motion) { porch lamp ON } else { porch lamp OFF }
The light reading is 380 and motion is not detected (false). What happens? (a) porch lamp OFF (b) porch lamp ON -
33.🤖 if (temperature > 37) { show “Hot” } else if (temperature > 20) { show “Warm” } else { show “Cool” }
The temperature is 15 °C. What is shown? (a) Warm (b) Cool (c) Hot -
34.🤖 if (moisture < 40) { pump ON } else { pump OFF }
The soil moisture sensor reads 27 %. What happens? (a) pump ON (b) pump OFF -
35.🤖 if (distance < 15) { buzzer beeps } else { buzzer is silent }
The distance sensor reads 18 cm. What happens? (a) buzzer beeps (b) buzzer is silent -
36.🤖 if (light < 400 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 -
37.🤖 if (sound > 70) { red LED ON } else { green LED ON }
The sound sensor reads 56. What happens? (a) red LED ON (b) green LED ON -
38.🤖 if (light < 400 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 OFF (b) porch lamp ON -
39.🤖 if (moisture < 30) { pump ON } else { pump OFF }
The soil moisture sensor reads 43 %. What happens? (a) pump ON (b) pump OFF -
40.🤖 if (light < 200 AND motion) { porch lamp ON } else { porch lamp OFF }
The light reading is 170 and motion is detected (true). What happens? (a) porch lamp OFF (b) porch lamp ON
Answer key
- porch lamp ON
- porch lamp ON
- the else part
- buzzer is silent
- buzzer is silent
- porch lamp ON
- Cool
- Warm
- buzzer is silent
- porch lamp OFF
- Hot
- Cool
- porch lamp OFF
- lamp OFF
- porch lamp ON
- porch lamp ON
- porch lamp OFF
- pump ON
- porch lamp ON
- Hot
- both A and B are true
- red LED ON
- porch lamp ON
- lamp ON
- Warm
- lamp ON
- lamp OFF
- lamp OFF
- Hot
- Warm
- red LED ON
- porch lamp OFF
- Cool
- pump ON
- buzzer is silent
- porch lamp ON
- green LED ON
- porch lamp OFF
- pump OFF
- porch lamp ON
Free electronics lessons, practice and worksheets at talentjr.in/electronics-for-kids