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