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