← If / else with sensors lesson New set →

Electronics Worksheet: If Else with Sensors

Electronics lesson 24: If / else with sensors · Set 432 · 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 < 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. 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. 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. 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. 5.🤖 if (light < 400) { lamp ON } else { lamp OFF }
    The light sensor reads 315. What happens?
    (a) lamp OFF (b) lamp ON
  6. 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. 7.🤖 if (temperature > 25) { fan ON } else { fan OFF }
    The temperature sensor reads 22 °C. What happens?
    (a) fan ON (b) fan OFF
  8. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 18.🤖 if (moisture < 50) { pump ON } else { pump OFF }
    The soil moisture sensor reads 68 %. 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 150 and motion is not detected (false). What happens?
    (a) porch lamp OFF (b) porch lamp ON
  20. 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. 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. 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. 23.🤖 if (moisture < 50) { pump ON } else { pump OFF }
    The soil moisture sensor reads 55 %. What happens?
    (a) pump OFF (b) pump ON
  24. 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. 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. 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. 27.🤖 if (moisture < 30) { pump ON } else { pump OFF }
    The soil moisture sensor reads 37 %. What happens?
    (a) pump OFF (b) pump ON
  28. 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. 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. 30.🤖 if (temperature > 28) { fan ON } else { fan OFF }
    The temperature sensor reads 29 °C. What happens?
    (a) fan ON (b) fan OFF
  31. 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. 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. 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. 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. 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. 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. 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. 38.🤖 if (moisture < 40) { pump ON } else { pump OFF }
    The soil moisture sensor reads 34 %. What happens?
    (a) pump ON (b) pump OFF
  39. 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. 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

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

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