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 > 31) { show “Hot” } else if (temperature > 20) { show “Warm” } else { show “Cool” }
The temperature is 11 °C. What is shown? (a) Warm (b) Cool (c) Hot - 2.🤖 “if (A AND B)” is true when … (a) only A is true (b) both A and B are true (c) both are false (d) only B is true
-
3.🤖 if (light < 300 AND motion) { porch lamp ON } else { porch lamp OFF }
The light reading is 610 and motion is detected (true). What happens? (a) porch lamp OFF (b) porch lamp ON -
4.🤖 if (light < 200 OR motion) { porch lamp ON } else { porch lamp OFF }
The light reading is 470 and motion is not detected (false). What happens? (a) porch lamp ON (b) porch lamp OFF -
5.🤖 if (temperature > 31) { show “Hot” } else if (temperature > 18) { show “Warm” } else { show “Cool” }
The temperature is 14 °C. What is shown? (a) Cool (b) Hot (c) Warm -
6.🤖 if (light < 500) { lamp ON } else { lamp OFF }
The light sensor reads 569. What happens? (a) lamp ON (b) lamp OFF -
7.🤖 if (distance < 30) { buzzer beeps } else { buzzer is silent }
The distance sensor reads 21 cm. What happens? (a) buzzer beeps (b) buzzer is silent -
8.🤖 if (distance < 10) { buzzer beeps } else { buzzer is silent }
The distance sensor reads 19 cm. What happens? (a) buzzer beeps (b) buzzer is silent -
9.🤖 if (temperature > 35) { show “Hot” } else if (temperature > 26) { show “Warm” } else { show “Cool” }
The temperature is 34 °C. What is shown? (a) Cool (b) Hot (c) Warm - 10.🤖 In “if (temp > 30)”, what runs when temp is exactly 30? (a) neither part (b) both parts (c) the if part (d) the else part
-
11.🤖 if (temperature > 31) { show “Hot” } else if (temperature > 20) { show “Warm” } else { show “Cool” }
The temperature is 19 °C. What is shown? (a) Cool (b) Warm (c) Hot -
12.🤖 if (temperature > 35) { show “Hot” } else if (temperature > 20) { show “Warm” } else { show “Cool” }
The temperature is 18 °C. What is shown? (a) Cool (b) Warm (c) Hot -
13.🤖 if (temperature > 28) { fan ON } else { fan OFF }
The temperature sensor reads 21 °C. What happens? (a) fan ON (b) fan OFF -
14.🤖 if (sound > 80) { red LED ON } else { green LED ON }
The sound sensor reads 73. What happens? (a) red LED ON (b) green LED ON -
15.🤖 if (sound > 70) { red LED ON } else { green LED ON }
The sound sensor reads 57. What happens? (a) red LED ON (b) green LED ON -
16.🤖 if (light < 200) { lamp ON } else { lamp OFF }
The light sensor reads 221. What happens? (a) lamp OFF (b) lamp ON -
17.🤖 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 -
18.🤖 if (light < 500) { lamp ON } else { lamp OFF }
The light sensor reads 444. What happens? (a) lamp ON (b) lamp OFF -
19.🤖 if (distance < 10) { buzzer beeps } else { buzzer is silent }
The distance sensor reads 18 cm. What happens? (a) buzzer beeps (b) buzzer is silent -
20.🤖 if (temperature > 38) { show “Hot” } else if (temperature > 18) { show “Warm” } else { show “Cool” }
The temperature is 15 °C. What is shown? (a) Cool (b) Hot (c) Warm -
21.🤖 if (temperature > 30) { show “Hot” } else if (temperature > 18) { show “Warm” } else { show “Cool” }
The temperature is 22 °C. What is shown? (a) Warm (b) Hot (c) Cool -
22.🤖 if (sound > 70) { red LED ON } else { green LED ON }
The sound sensor reads 68. What happens? (a) green LED ON (b) red LED ON -
23.🤖 if (light < 300) { lamp ON } else { lamp OFF }
The light sensor reads 446. What happens? (a) lamp ON (b) lamp OFF -
24.🤖 if (temperature > 30) { fan ON } else { fan OFF }
The temperature sensor reads 32 °C. What happens? (a) fan OFF (b) fan ON -
25.🤖 if (light < 200 OR motion) { porch lamp ON } else { porch lamp OFF }
The light reading is 250 and motion is not detected (false). What happens? (a) porch lamp ON (b) porch lamp OFF -
26.🤖 if (light < 300 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 OFF (b) porch lamp ON -
27.🤖 if (temperature > 31) { show “Hot” } else if (temperature > 18) { show “Warm” } else { show “Cool” }
The temperature is 32 °C. What is shown? (a) Cool (b) Hot (c) Warm -
28.🤖 if (temperature > 36) { show “Hot” } else if (temperature > 25) { show “Warm” } else { show “Cool” }
The temperature is 16 °C. What is shown? (a) Hot (b) Warm (c) Cool -
29.🤖 if (distance < 15) { buzzer beeps } else { buzzer is silent }
The distance sensor reads 13 cm. What happens? (a) buzzer beeps (b) buzzer is silent -
30.🤖 if (temperature > 32) { fan ON } else { fan OFF }
The temperature sensor reads 32 °C. What happens? (a) fan ON (b) fan OFF -
31.🤖 if (temperature > 32) { show “Hot” } else if (temperature > 20) { show “Warm” } else { show “Cool” }
The temperature is 43 °C. What is shown? (a) Hot (b) Cool (c) Warm -
32.🤖 if (light < 400 OR 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 -
33.🤖 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 -
34.🤖 if (temperature > 25) { fan ON } else { fan OFF }
The temperature sensor reads 31 °C. What happens? (a) fan ON (b) fan OFF -
35.🤖 if (light < 300 OR motion) { porch lamp ON } else { porch lamp OFF }
The light reading is 640 and motion is detected (true). What happens? (a) porch lamp ON (b) porch lamp OFF -
36.🤖 if (light < 200) { lamp ON } else { lamp OFF }
The light sensor reads 292. What happens? (a) lamp OFF (b) lamp ON -
37.🤖 if (light < 500) { lamp ON } else { lamp OFF }
The light sensor reads 576. What happens? (a) lamp ON (b) lamp OFF -
38.🤖 if (temperature > 35) { show “Hot” } else if (temperature > 26) { show “Warm” } else { show “Cool” }
The temperature is 30 °C. What is shown? (a) Cool (b) Hot (c) Warm -
39.🤖 if (distance < 30) { buzzer beeps } else { buzzer is silent }
The distance sensor reads 25 cm. What happens? (a) buzzer is silent (b) buzzer beeps -
40.🤖 if (temperature > 36) { show “Hot” } else if (temperature > 21) { show “Warm” } else { show “Cool” }
The temperature is 40 °C. What is shown? (a) Warm (b) Cool (c) Hot
Answer key
- Cool
- both A and B are true
- porch lamp OFF
- porch lamp OFF
- Cool
- lamp OFF
- buzzer beeps
- buzzer is silent
- Warm
- the else part
- Cool
- Cool
- fan OFF
- green LED ON
- green LED ON
- lamp OFF
- porch lamp ON
- lamp ON
- buzzer is silent
- Cool
- Warm
- green LED ON
- lamp OFF
- fan ON
- porch lamp OFF
- porch lamp OFF
- Hot
- Cool
- buzzer beeps
- fan OFF
- Hot
- porch lamp ON
- green LED ON
- fan ON
- porch lamp ON
- lamp OFF
- lamp OFF
- Warm
- buzzer beeps
- Hot
Free electronics lessons, practice and worksheets at talentjr.in/electronics-for-kids