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