← If / else with sensors lesson New set →

Electronics Worksheet: If Else with Sensors

Electronics lesson 24: If / else with sensors · Set 549 · 40 questions
TalentJR

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. 1.🤖 In “if (temp > 30)”, what runs when temp is exactly 30? (a) the else part (b) neither part (c) the if part (d) both parts
  2. 2.🤖 if (light < 300 AND 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
  3. 3.🤖 if (light < 400) { lamp ON } else { lamp OFF }
    The light sensor reads 501. What happens?
    (a) lamp OFF (b) lamp ON
  4. 4.🤖 if (temperature > 31) { show “Hot” } else if (temperature > 23) { show “Warm” } else { show “Cool” }
    The temperature is 17 °C. What is shown?
    (a) Cool (b) Hot (c) Warm
  5. 5.🤖 if (light < 200 OR motion) { porch lamp ON } else { porch lamp OFF }
    The light reading is 220 and motion is detected (true). What happens?
    (a) porch lamp OFF (b) porch lamp ON
  6. 6.🤖 if (light < 400 AND motion) { porch lamp ON } else { porch lamp OFF }
    The light reading is 120 and motion is detected (true). What happens?
    (a) porch lamp OFF (b) porch lamp ON
  7. 7.🤖 if (light < 400 AND motion) { porch lamp ON } else { porch lamp OFF }
    The light reading is 230 and motion is detected (true). What happens?
    (a) porch lamp ON (b) porch lamp OFF
  8. 8.🤖 if (temperature > 30) { show “Hot” } else if (temperature > 24) { show “Warm” } else { show “Cool” }
    The temperature is 13 °C. What is shown?
    (a) Cool (b) Hot (c) Warm
  9. 9.🤖 if (distance < 20) { buzzer beeps } else { buzzer is silent }
    The distance sensor reads 19 cm. What happens?
    (a) buzzer beeps (b) buzzer is silent
  10. 10.🤖 if (sound > 70) { red LED ON } else { green LED ON }
    The sound sensor reads 69. What happens?
    (a) red LED ON (b) green LED ON
  11. 11.🤖 if (light < 300 AND motion) { porch lamp ON } else { porch lamp OFF }
    The light reading is 310 and motion is detected (true). What happens?
    (a) porch lamp ON (b) porch lamp OFF
  12. 12.🤖 if (distance < 30) { buzzer beeps } else { buzzer is silent }
    The distance sensor reads 32 cm. What happens?
    (a) buzzer is silent (b) buzzer beeps
  13. 13.🤖 if (sound > 80) { red LED ON } else { green LED ON }
    The sound sensor reads 69. What happens?
    (a) red LED ON (b) green LED ON
  14. 14.🤖 if (light < 400) { lamp ON } else { lamp OFF }
    The light sensor reads 344. What happens?
    (a) lamp ON (b) lamp OFF
  15. 15.🤖 if (temperature > 30) { fan ON } else { fan OFF }
    The temperature sensor reads 23 °C. What happens?
    (a) fan ON (b) fan OFF
  16. 16.🤖 if (moisture < 50) { pump ON } else { pump OFF }
    The soil moisture sensor reads 59 %. What happens?
    (a) pump ON (b) pump OFF
  17. 17.🤖 if (light < 300 OR motion) { porch lamp ON } else { porch lamp OFF }
    The light reading is 130 and motion is detected (true). What happens?
    (a) porch lamp OFF (b) porch lamp ON
  18. 18.🤖 if (moisture < 40) { pump ON } else { pump OFF }
    The soil moisture sensor reads 53 %. What happens?
    (a) pump ON (b) pump OFF
  19. 19.🤖 if (light < 200 AND motion) { porch lamp ON } else { porch lamp OFF }
    The light reading is 430 and motion is not detected (false). What happens?
    (a) porch lamp OFF (b) porch lamp ON
  20. 20.🤖 “if (A AND B)” is true when … (a) both are false (b) only B is true (c) only A is true (d) both A and B are true
  21. 21.🤖 if (temperature > 34) { show “Hot” } else if (temperature > 26) { show “Warm” } else { show “Cool” }
    The temperature is 36 °C. What is shown?
    (a) Warm (b) Cool (c) Hot
  22. 22.🤖 if (light < 200 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
  23. 23.🤖 if (sound > 80) { red LED ON } else { green LED ON }
    The sound sensor reads 92. What happens?
    (a) red LED ON (b) green LED ON
  24. 24.🤖 if (moisture < 30) { pump ON } else { pump OFF }
    The soil moisture sensor reads 41 %. What happens?
    (a) pump OFF (b) pump ON
  25. 25.🤖 if (temperature > 33) { show “Hot” } else if (temperature > 26) { show “Warm” } else { show “Cool” }
    The temperature is 40 °C. What is shown?
    (a) Cool (b) Warm (c) Hot
  26. 26.🤖 if (light < 400 OR motion) { porch lamp ON } else { porch lamp OFF }
    The light reading is 570 and motion is detected (true). What happens?
    (a) porch lamp ON (b) porch lamp OFF
  27. 27.🤖 if (sound > 70) { red LED ON } else { green LED ON }
    The sound sensor reads 70. What happens?
    (a) red LED ON (b) green LED ON
  28. 28.🤖 if (distance < 20) { buzzer beeps } else { buzzer is silent }
    The distance sensor reads 14 cm. What happens?
    (a) buzzer beeps (b) buzzer is silent
  29. 29.🤖 if (light < 200) { lamp ON } else { lamp OFF }
    The light sensor reads 63. What happens?
    (a) lamp ON (b) lamp OFF
  30. 30.🤖 if (moisture < 50) { pump ON } else { pump OFF }
    The soil moisture sensor reads 46 %. What happens?
    (a) pump OFF (b) pump ON
  31. 31.🤖 if (distance < 15) { buzzer beeps } else { buzzer is silent }
    The distance sensor reads 20 cm. What happens?
    (a) buzzer is silent (b) buzzer beeps
  32. 32.🤖 if (temperature > 35) { show “Hot” } else if (temperature > 20) { show “Warm” } else { show “Cool” }
    The temperature is 16 °C. What is shown?
    (a) Warm (b) Hot (c) Cool
  33. 33.🤖 if (temperature > 32) { show “Hot” } else if (temperature > 20) { show “Warm” } else { show “Cool” }
    The temperature is 35 °C. What is shown?
    (a) Hot (b) Warm (c) Cool
  34. 34.🤖 if (temperature > 32) { fan ON } else { fan OFF }
    The temperature sensor reads 38 °C. What happens?
    (a) fan OFF (b) fan ON
  35. 35.🤖 if (temperature > 37) { show “Hot” } else if (temperature > 22) { show “Warm” } else { show “Cool” }
    The temperature is 12 °C. What is shown?
    (a) Warm (b) Hot (c) Cool
  36. 36.🤖 if (light < 200 OR motion) { porch lamp ON } else { porch lamp OFF }
    The light reading is 490 and motion is not detected (false). What happens?
    (a) porch lamp ON (b) porch lamp OFF
  37. 37.🤖 if (light < 400) { lamp ON } else { lamp OFF }
    The light sensor reads 470. What happens?
    (a) lamp OFF (b) lamp ON
  38. 38.🤖 if (temperature > 32) { show “Hot” } else if (temperature > 24) { show “Warm” } else { show “Cool” }
    The temperature is 45 °C. What is shown?
    (a) Warm (b) Cool (c) Hot
  39. 39.🤖 if (temperature > 35) { show “Hot” } else if (temperature > 26) { show “Warm” } else { show “Cool” }
    The temperature is 16 °C. What is shown?
    (a) Hot (b) Cool (c) Warm
  40. 40.🤖 if (temperature > 32) { show “Hot” } else if (temperature > 21) { show “Warm” } else { show “Cool” }
    The temperature is 12 °C. What is shown?
    (a) Warm (b) Cool (c) Hot

Answer key

  1. the else part
  2. porch lamp OFF
  3. lamp OFF
  4. Cool
  5. porch lamp ON
  6. porch lamp ON
  7. porch lamp ON
  8. Cool
  9. buzzer beeps
  10. green LED ON
  11. porch lamp OFF
  12. buzzer is silent
  13. green LED ON
  14. lamp ON
  15. fan OFF
  16. pump OFF
  17. porch lamp ON
  18. pump OFF
  19. porch lamp OFF
  20. both A and B are true
  21. Hot
  22. porch lamp OFF
  23. red LED ON
  24. pump OFF
  25. Hot
  26. porch lamp ON
  27. green LED ON
  28. buzzer beeps
  29. lamp ON
  30. pump ON
  31. buzzer is silent
  32. Cool
  33. Hot
  34. fan ON
  35. Cool
  36. porch lamp OFF
  37. lamp OFF
  38. Hot
  39. Cool
  40. Cool

Free electronics lessons, practice and worksheets at talentjr.in/electronics-for-kids