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