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