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