← If / else with sensors lesson New set →

Electronics Worksheet: If Else with Sensors

Electronics lesson 24: If / else with sensors · Set 102 · 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.🤖 if (light < 200 OR motion) { porch lamp ON } else { porch lamp OFF }
    The light reading is 430 and motion is detected (true). What happens?
    (a) porch lamp OFF (b) porch lamp ON
  2. 2.🤖 if (light < 200) { lamp ON } else { lamp OFF }
    The light sensor reads 55. What happens?
    (a) lamp ON (b) lamp OFF
  3. 3.🤖 if (light < 400 OR motion) { porch lamp ON } else { porch lamp OFF }
    The light reading is 240 and motion is detected (true). What happens?
    (a) porch lamp ON (b) porch lamp OFF
  4. 4.🤖 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
  5. 5.🤖 “if (A AND B)” is true when … (a) only A is true (b) only B is true (c) both A and B are true (d) both are false
  6. 6.🤖 if (sound > 70) { red LED ON } else { green LED ON }
    The sound sensor reads 83. What happens?
    (a) green LED ON (b) red LED ON
  7. 7.🤖 if (light < 200 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
  8. 8.🤖 if (light < 400 OR motion) { porch lamp ON } else { porch lamp OFF }
    The light reading is 340 and motion is detected (true). What happens?
    (a) porch lamp ON (b) porch lamp OFF
  9. 9.🤖 if (light < 400 OR motion) { porch lamp ON } else { porch lamp OFF }
    The light reading is 140 and motion is detected (true). What happens?
    (a) porch lamp OFF (b) porch lamp ON
  10. 10.🤖 if (light < 200 OR motion) { porch lamp ON } else { porch lamp OFF }
    The light reading is 620 and motion is not detected (false). What happens?
    (a) porch lamp OFF (b) porch lamp ON
  11. 11.🤖 if (temperature > 31) { show “Hot” } else if (temperature > 22) { show “Warm” } else { show “Cool” }
    The temperature is 19 °C. What is shown?
    (a) Hot (b) Warm (c) Cool
  12. 12.🤖 if (temperature > 31) { show “Hot” } else if (temperature > 21) { show “Warm” } else { show “Cool” }
    The temperature is 26 °C. What is shown?
    (a) Hot (b) Cool (c) Warm
  13. 13.🤖 if (temperature > 30) { fan ON } else { fan OFF }
    The temperature sensor reads 36 °C. What happens?
    (a) fan ON (b) fan OFF
  14. 14.🤖 if (light < 200 AND 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
  15. 15.🤖 if (temperature > 31) { show “Hot” } else if (temperature > 24) { show “Warm” } else { show “Cool” }
    The temperature is 26 °C. What is shown?
    (a) Hot (b) Warm (c) Cool
  16. 16.🤖 if (light < 200 OR motion) { porch lamp ON } else { porch lamp OFF }
    The light reading is 110 and motion is detected (true). What happens?
    (a) porch lamp ON (b) porch lamp OFF
  17. 17.🤖 if (temperature > 34) { show “Hot” } else if (temperature > 19) { show “Warm” } else { show “Cool” }
    The temperature is 40 °C. What is shown?
    (a) Cool (b) Warm (c) Hot
  18. 18.🤖 if (temperature > 30) { show “Hot” } else if (temperature > 22) { show “Warm” } else { show “Cool” }
    The temperature is 11 °C. What is shown?
    (a) Cool (b) Warm (c) Hot
  19. 19.🤖 if (light < 300 OR motion) { porch lamp ON } else { porch lamp OFF }
    The light reading is 490 and motion is detected (true). What happens?
    (a) porch lamp ON (b) porch lamp OFF
  20. 20.🤖 if (temperature > 32) { show “Hot” } else if (temperature > 22) { show “Warm” } else { show “Cool” }
    The temperature is 28 °C. What is shown?
    (a) Warm (b) Hot (c) Cool
  21. 21.🤖 if (light < 200 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
  22. 22.🤖 if (temperature > 38) { show “Hot” } else if (temperature > 21) { show “Warm” } else { show “Cool” }
    The temperature is 44 °C. What is shown?
    (a) Warm (b) Cool (c) Hot
  23. 23.🤖 if (light < 200 AND motion) { porch lamp ON } else { porch lamp OFF }
    The light reading is 230 and motion is not detected (false). What happens?
    (a) porch lamp ON (b) porch lamp OFF
  24. 24.🤖 if (light < 300 OR motion) { porch lamp ON } else { porch lamp OFF }
    The light reading is 250 and motion is detected (true). What happens?
    (a) porch lamp OFF (b) porch lamp ON
  25. 25.🤖 if (light < 400 OR 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
  26. 26.🤖 if (light < 200) { lamp ON } else { lamp OFF }
    The light sensor reads 249. What happens?
    (a) lamp OFF (b) lamp ON
  27. 27.🤖 if (light < 300 OR motion) { porch lamp ON } else { porch lamp OFF }
    The light reading is 110 and motion is detected (true). What happens?
    (a) porch lamp OFF (b) porch lamp ON
  28. 28.🤖 if (light < 400 AND motion) { porch lamp ON } else { porch lamp OFF }
    The light reading is 120 and motion is not detected (false). What happens?
    (a) porch lamp ON (b) porch lamp OFF
  29. 29.🤖 if (temperature > 25) { fan ON } else { fan OFF }
    The temperature sensor reads 24 °C. What happens?
    (a) fan ON (b) fan OFF
  30. 30.🤖 if (temperature > 32) { show “Hot” } else if (temperature > 21) { show “Warm” } else { show “Cool” }
    The temperature is 39 °C. What is shown?
    (a) Warm (b) Cool (c) Hot
  31. 31.🤖 if (temperature > 30) { show “Hot” } else if (temperature > 26) { show “Warm” } else { show “Cool” }
    The temperature is 28 °C. What is shown?
    (a) Warm (b) Cool (c) Hot
  32. 32.🤖 if (light < 200 OR motion) { porch lamp ON } else { porch lamp OFF }
    The light reading is 120 and motion is not detected (false). What happens?
    (a) porch lamp OFF (b) porch lamp ON
  33. 33.🤖 if (light < 300 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
  34. 34.🤖 if (temperature > 31) { show “Hot” } else if (temperature > 25) { show “Warm” } else { show “Cool” }
    The temperature is 16 °C. What is shown?
    (a) Hot (b) Cool (c) Warm
  35. 35.🤖 if (light < 200 OR motion) { porch lamp ON } else { porch lamp OFF }
    The light reading is 340 and motion is detected (true). What happens?
    (a) porch lamp OFF (b) porch lamp ON
  36. 36.🤖 if (light < 400 AND motion) { porch lamp ON } else { porch lamp OFF }
    The light reading is 490 and motion is detected (true). What happens?
    (a) porch lamp OFF (b) porch lamp ON
  37. 37.🤖 if (light < 300 AND motion) { porch lamp ON } else { porch lamp OFF }
    The light reading is 590 and motion is detected (true). What happens?
    (a) porch lamp ON (b) porch lamp OFF
  38. 38.🤖 if (temperature > 30) { show “Hot” } else if (temperature > 18) { show “Warm” } else { show “Cool” }
    The temperature is 31 °C. What is shown?
    (a) Warm (b) Hot (c) Cool
  39. 39.🤖 if (light < 400 AND motion) { porch lamp ON } else { porch lamp OFF }
    The light reading is 250 and motion is detected (true). What happens?
    (a) porch lamp OFF (b) porch lamp ON
  40. 40.🤖 if (distance < 30) { buzzer beeps } else { buzzer is silent }
    The distance sensor reads 21 cm. What happens?
    (a) buzzer is silent (b) buzzer beeps

Answer key

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

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