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