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