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