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 < 300 AND motion) { porch lamp ON } else { porch lamp OFF }
The light reading is 150 and motion is detected (true). What happens? (a) porch lamp ON (b) porch lamp OFF - 2.🤖 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
-
3.🤖 if (temperature > 37) { show “Hot” } else if (temperature > 26) { show “Warm” } else { show “Cool” }
The temperature is 18 °C. What is shown? (a) Hot (b) Warm (c) Cool -
4.🤖 if (distance < 30) { buzzer beeps } else { buzzer is silent }
The distance sensor reads 24 cm. What happens? (a) buzzer beeps (b) buzzer is silent -
5.🤖 if (light < 400) { lamp ON } else { lamp OFF }
The light sensor reads 315. What happens? (a) lamp OFF (b) lamp ON -
6.🤖 if (light < 200 OR motion) { porch lamp ON } else { porch lamp OFF }
The light reading is 90 and motion is detected (true). What happens? (a) porch lamp ON (b) porch lamp OFF -
7.🤖 if (temperature > 25) { fan ON } else { fan OFF }
The temperature sensor reads 22 °C. What happens? (a) fan ON (b) fan OFF -
8.🤖 if (distance < 30) { buzzer beeps } else { buzzer is silent }
The distance sensor reads 35 cm. What happens? (a) buzzer beeps (b) buzzer is silent -
9.🤖 if (temperature > 32) { show “Hot” } else if (temperature > 21) { show “Warm” } else { show “Cool” }
The temperature is 33 °C. What is shown? (a) Warm (b) Cool (c) Hot -
10.🤖 if (light < 300 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 -
11.🤖 if (light < 400 AND motion) { porch lamp ON } else { porch lamp OFF }
The light reading is 170 and motion is detected (true). What happens? (a) porch lamp OFF (b) porch lamp ON -
12.🤖 if (light < 300 AND motion) { porch lamp ON } else { porch lamp OFF }
The light reading is 440 and motion is detected (true). What happens? (a) porch lamp OFF (b) porch lamp ON -
13.🤖 if (light < 200 OR motion) { porch lamp ON } else { porch lamp OFF }
The light reading is 380 and motion is detected (true). What happens? (a) porch lamp OFF (b) porch lamp ON -
14.🤖 if (distance < 10) { buzzer beeps } else { buzzer is silent }
The distance sensor reads 2 cm. What happens? (a) buzzer is silent (b) buzzer beeps -
15.🤖 if (light < 400 OR motion) { porch lamp ON } else { porch lamp OFF }
The light reading is 60 and motion is detected (true). What happens? (a) porch lamp OFF (b) porch lamp ON - 16.🤖 “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
-
17.🤖 if (distance < 20) { buzzer beeps } else { buzzer is silent }
The distance sensor reads 11 cm. What happens? (a) buzzer beeps (b) buzzer is silent -
18.🤖 if (moisture < 50) { pump ON } else { pump OFF }
The soil moisture sensor reads 68 %. What happens? (a) pump ON (b) pump OFF -
19.🤖 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 -
20.🤖 if (light < 200 AND motion) { porch lamp ON } else { porch lamp OFF }
The light reading is 80 and motion is not detected (false). What happens? (a) porch lamp ON (b) porch lamp OFF -
21.🤖 if (light < 200 OR motion) { porch lamp ON } else { porch lamp OFF }
The light reading is 640 and motion is detected (true). What happens? (a) porch lamp OFF (b) porch lamp ON -
22.🤖 if (temperature > 33) { show “Hot” } else if (temperature > 21) { show “Warm” } else { show “Cool” }
The temperature is 29 °C. What is shown? (a) Warm (b) Cool (c) Hot -
23.🤖 if (moisture < 50) { pump ON } else { pump OFF }
The soil moisture sensor reads 55 %. What happens? (a) pump OFF (b) pump ON -
24.🤖 if (light < 200 AND motion) { porch lamp ON } else { porch lamp OFF }
The light reading is 380 and motion is not detected (false). What happens? (a) porch lamp ON (b) porch lamp OFF -
25.🤖 if (light < 300 OR motion) { porch lamp ON } else { porch lamp OFF }
The light reading is 60 and motion is detected (true). What happens? (a) porch lamp OFF (b) porch lamp ON -
26.🤖 if (light < 400 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 -
27.🤖 if (moisture < 30) { pump ON } else { pump OFF }
The soil moisture sensor reads 37 %. What happens? (a) pump OFF (b) pump ON -
28.🤖 if (light < 400 AND motion) { porch lamp ON } else { porch lamp OFF }
The light reading is 410 and motion is not detected (false). What happens? (a) porch lamp ON (b) porch lamp OFF -
29.🤖 if (light < 400 AND motion) { porch lamp ON } else { porch lamp OFF }
The light reading is 400 and motion is not detected (false). What happens? (a) porch lamp OFF (b) porch lamp ON -
30.🤖 if (temperature > 28) { fan ON } else { fan OFF }
The temperature sensor reads 29 °C. What happens? (a) fan ON (b) fan OFF -
31.🤖 if (light < 400 AND motion) { porch lamp ON } else { porch lamp OFF }
The light reading is 500 and motion is not detected (false). What happens? (a) porch lamp ON (b) porch lamp OFF -
32.🤖 if (light < 200 AND motion) { porch lamp ON } else { porch lamp OFF }
The light reading is 200 and motion is not detected (false). What happens? (a) porch lamp ON (b) porch lamp OFF -
33.🤖 if (temperature > 36) { show “Hot” } else if (temperature > 25) { show “Warm” } else { show “Cool” }
The temperature is 40 °C. What is shown? (a) Warm (b) Hot (c) Cool -
34.🤖 if (temperature > 36) { show “Hot” } else if (temperature > 20) { show “Warm” } else { show “Cool” }
The temperature is 38 °C. What is shown? (a) Warm (b) Cool (c) Hot -
35.🤖 if (temperature > 34) { show “Hot” } else if (temperature > 18) { show “Warm” } else { show “Cool” }
The temperature is 24 °C. What is shown? (a) Cool (b) Hot (c) Warm -
36.🤖 if (light < 300 OR motion) { porch lamp ON } else { porch lamp OFF }
The light reading is 510 and motion is not detected (false). What happens? (a) porch lamp ON (b) porch lamp OFF -
37.🤖 if (temperature > 36) { show “Hot” } else if (temperature > 26) { show “Warm” } else { show “Cool” }
The temperature is 28 °C. What is shown? (a) Hot (b) Warm (c) Cool -
38.🤖 if (moisture < 40) { pump ON } else { pump OFF }
The soil moisture sensor reads 34 %. What happens? (a) pump ON (b) pump OFF -
39.🤖 if (light < 200 OR motion) { porch lamp ON } else { porch lamp OFF }
The light reading is 640 and motion is not detected (false). What happens? (a) porch lamp OFF (b) porch lamp ON -
40.🤖 if (temperature > 37) { show “Hot” } else if (temperature > 19) { show “Warm” } else { show “Cool” }
The temperature is 20 °C. What is shown? (a) Hot (b) Warm (c) Cool
Answer key
- porch lamp ON
- the else part
- Cool
- buzzer beeps
- lamp ON
- porch lamp ON
- fan OFF
- buzzer is silent
- Hot
- porch lamp ON
- porch lamp ON
- porch lamp OFF
- porch lamp ON
- buzzer beeps
- porch lamp ON
- both A and B are true
- buzzer beeps
- pump OFF
- porch lamp OFF
- porch lamp OFF
- porch lamp ON
- Warm
- pump OFF
- porch lamp OFF
- porch lamp ON
- porch lamp OFF
- pump OFF
- porch lamp OFF
- porch lamp OFF
- fan ON
- porch lamp OFF
- porch lamp OFF
- Hot
- Hot
- Warm
- porch lamp OFF
- Warm
- pump ON
- porch lamp OFF
- Warm
Free electronics lessons, practice and worksheets at talentjr.in/electronics-for-kids