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