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) neither part (c) the else part (d) both parts
-
2.🤖 if (temperature > 32) { show “Hot” } else if (temperature > 26) { show “Warm” } else { show “Cool” }
The temperature is 20 °C. What is shown? (a) Cool (b) Warm (c) Hot -
3.🤖 if (light < 200) { lamp ON } else { lamp OFF }
The light sensor reads 331. What happens? (a) lamp OFF (b) lamp ON -
4.🤖 if (temperature > 33) { show “Hot” } else if (temperature > 23) { show “Warm” } else { show “Cool” }
The temperature is 41 °C. What is shown? (a) Cool (b) Warm (c) Hot -
5.🤖 if (light < 200 OR motion) { porch lamp ON } else { porch lamp OFF }
The light reading is 390 and motion is detected (true). What happens? (a) porch lamp OFF (b) porch lamp ON -
6.🤖 if (light < 200 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 -
7.🤖 if (light < 200 OR 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 -
8.🤖 if (light < 200 AND 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 -
9.🤖 if (light < 200 OR motion) { porch lamp ON } else { porch lamp OFF }
The light reading is 530 and motion is not detected (false). What happens? (a) porch lamp OFF (b) porch lamp ON - 10.🤖 “if (A AND B)” is true when … (a) only B is true (b) both are false (c) both A and B are true (d) only A is true
-
11.🤖 if (sound > 80) { red LED ON } else { green LED ON }
The sound sensor reads 95. What happens? (a) red LED ON (b) green LED ON -
12.🤖 if (temperature > 33) { show “Hot” } else if (temperature > 22) { show “Warm” } else { show “Cool” }
The temperature is 39 °C. What is shown? (a) Hot (b) Warm (c) Cool -
13.🤖 if (temperature > 34) { show “Hot” } else if (temperature > 26) { show “Warm” } else { show “Cool” }
The temperature is 23 °C. What is shown? (a) Hot (b) Cool (c) Warm -
14.🤖 if (temperature > 36) { show “Hot” } else if (temperature > 25) { show “Warm” } else { show “Cool” }
The temperature is 10 °C. What is shown? (a) Warm (b) Hot (c) Cool -
15.🤖 if (temperature > 38) { show “Hot” } else if (temperature > 22) { show “Warm” } else { show “Cool” }
The temperature is 18 °C. What is shown? (a) Hot (b) Warm (c) Cool -
16.🤖 if (light < 400 OR motion) { porch lamp ON } else { porch lamp OFF }
The light reading is 460 and motion is not detected (false). What happens? (a) porch lamp ON (b) porch lamp OFF -
17.🤖 if (temperature > 36) { show “Hot” } else if (temperature > 21) { show “Warm” } else { show “Cool” }
The temperature is 42 °C. What is shown? (a) Hot (b) Cool (c) Warm -
18.🤖 if (temperature > 37) { 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 -
19.🤖 if (light < 200 OR 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 -
20.🤖 if (distance < 15) { buzzer beeps } else { buzzer is silent }
The distance sensor reads 12 cm. What happens? (a) buzzer is silent (b) buzzer beeps -
21.🤖 if (light < 400 OR 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 -
22.🤖 if (light < 200 AND motion) { porch lamp ON } else { porch lamp OFF }
The light reading is 400 and motion is detected (true). What happens? (a) porch lamp OFF (b) porch lamp ON -
23.🤖 if (light < 200) { lamp ON } else { lamp OFF }
The light sensor reads 299. What happens? (a) lamp OFF (b) lamp ON -
24.🤖 if (light < 400 AND 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 -
25.🤖 if (light < 400 AND motion) { porch lamp ON } else { porch lamp OFF }
The light reading is 350 and motion is not detected (false). What happens? (a) porch lamp ON (b) porch lamp OFF -
26.🤖 if (temperature > 33) { show “Hot” } else if (temperature > 24) { show “Warm” } else { show “Cool” }
The temperature is 21 °C. What is shown? (a) Hot (b) Cool (c) Warm -
27.🤖 if (sound > 80) { red LED ON } else { green LED ON }
The sound sensor reads 71. What happens? (a) red LED ON (b) green LED ON -
28.🤖 if (light < 300 AND motion) { porch lamp ON } else { porch lamp OFF }
The light reading is 420 and motion is detected (true). What happens? (a) porch lamp OFF (b) porch lamp ON -
29.🤖 if (temperature > 34) { show “Hot” } else if (temperature > 21) { show “Warm” } else { show “Cool” }
The temperature is 40 °C. What is shown? (a) Cool (b) Hot (c) Warm -
30.🤖 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 -
31.🤖 if (moisture < 40) { pump ON } else { pump OFF }
The soil moisture sensor reads 47 %. What happens? (a) pump OFF (b) pump ON -
32.🤖 if (distance < 30) { buzzer beeps } else { buzzer is silent }
The distance sensor reads 21 cm. What happens? (a) buzzer beeps (b) buzzer is silent -
33.🤖 if (light < 400) { lamp ON } else { lamp OFF }
The light sensor reads 440. What happens? (a) lamp OFF (b) lamp ON -
34.🤖 if (light < 300 AND motion) { porch lamp ON } else { porch lamp OFF }
The light reading is 390 and motion is not detected (false). What happens? (a) porch lamp OFF (b) porch lamp ON -
35.🤖 if (distance < 30) { buzzer beeps } else { buzzer is silent }
The distance sensor reads 36 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 600 and motion is not detected (false). What happens? (a) porch lamp ON (b) porch lamp OFF -
37.🤖 if (light < 300) { lamp ON } else { lamp OFF }
The light sensor reads 190. What happens? (a) lamp OFF (b) lamp ON -
38.🤖 if (light < 300 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 -
39.🤖 if (light < 200 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 -
40.🤖 if (light < 200 AND 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
Answer key
- the else part
- Cool
- lamp OFF
- Hot
- porch lamp ON
- porch lamp OFF
- porch lamp ON
- porch lamp OFF
- porch lamp OFF
- both A and B are true
- red LED ON
- Hot
- Cool
- Cool
- Cool
- porch lamp OFF
- Hot
- Cool
- porch lamp OFF
- buzzer beeps
- porch lamp ON
- porch lamp OFF
- lamp OFF
- porch lamp ON
- porch lamp OFF
- Cool
- green LED ON
- porch lamp OFF
- Hot
- porch lamp ON
- pump OFF
- buzzer beeps
- lamp OFF
- porch lamp OFF
- buzzer is silent
- porch lamp OFF
- lamp ON
- porch lamp ON
- porch lamp ON
- porch lamp ON
Free electronics lessons, practice and worksheets at talentjr.in/electronics-for-kids