← If / else with sensors lesson New set →

Electronics Worksheet: If Else with Sensors

Electronics lesson 24: If / else with sensors · Set 19 · 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 if part (b) neither part (c) the else part (d) both parts
  2. 2.🤖 if (temperature > 32) { show “Hot” } else if (temperature > 26) { show “Warm” } else { show “Cool” }
    The temperature is 20 °C. What is shown?
    (a) Cool (b) Warm (c) Hot
  3. 3.🤖 if (light < 200) { lamp ON } else { lamp OFF }
    The light sensor reads 331. What happens?
    (a) lamp OFF (b) lamp ON
  4. 4.🤖 if (temperature > 33) { show “Hot” } else if (temperature > 23) { show “Warm” } else { show “Cool” }
    The temperature is 41 °C. What is shown?
    (a) Cool (b) Warm (c) Hot
  5. 5.🤖 if (light < 200 OR 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
  6. 6.🤖 if (light < 200 AND motion) { porch lamp ON } else { porch lamp OFF }
    The light reading is 360 and motion is not detected (false). What happens?
    (a) porch lamp OFF (b) porch lamp ON
  7. 7.🤖 if (light < 200 OR 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
  8. 8.🤖 if (light < 200 AND motion) { porch lamp ON } else { porch lamp OFF }
    The light reading is 470 and motion is not detected (false). What happens?
    (a) porch lamp ON (b) porch lamp OFF
  9. 9.🤖 if (light < 200 OR motion) { porch lamp ON } else { porch lamp OFF }
    The light reading is 530 and motion is not detected (false). What happens?
    (a) porch lamp OFF (b) porch lamp ON
  10. 10.🤖 “if (A AND B)” is true when … (a) only B is true (b) both are false (c) both A and B are true (d) only A is true
  11. 11.🤖 if (sound > 80) { red LED ON } else { green LED ON }
    The sound sensor reads 95. What happens?
    (a) red LED ON (b) green LED ON
  12. 12.🤖 if (temperature > 33) { show “Hot” } else if (temperature > 22) { show “Warm” } else { show “Cool” }
    The temperature is 39 °C. What is shown?
    (a) Hot (b) Warm (c) Cool
  13. 13.🤖 if (temperature > 34) { show “Hot” } else if (temperature > 26) { show “Warm” } else { show “Cool” }
    The temperature is 23 °C. What is shown?
    (a) Hot (b) Cool (c) Warm
  14. 14.🤖 if (temperature > 36) { show “Hot” } else if (temperature > 25) { show “Warm” } else { show “Cool” }
    The temperature is 10 °C. What is shown?
    (a) Warm (b) Hot (c) Cool
  15. 15.🤖 if (temperature > 38) { show “Hot” } else if (temperature > 22) { show “Warm” } else { show “Cool” }
    The temperature is 18 °C. What is shown?
    (a) Hot (b) Warm (c) Cool
  16. 16.🤖 if (light < 400 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 ON (b) porch lamp OFF
  17. 17.🤖 if (temperature > 36) { show “Hot” } else if (temperature > 21) { show “Warm” } else { show “Cool” }
    The temperature is 42 °C. What is shown?
    (a) Hot (b) Cool (c) Warm
  18. 18.🤖 if (temperature > 37) { show “Hot” } else if (temperature > 25) { show “Warm” } else { show “Cool” }
    The temperature is 11 °C. What is shown?
    (a) Hot (b) Cool (c) Warm
  19. 19.🤖 if (light < 200 OR motion) { porch lamp ON } else { porch lamp OFF }
    The light reading is 320 and motion is not detected (false). What happens?
    (a) porch lamp ON (b) porch lamp OFF
  20. 20.🤖 if (distance < 15) { buzzer beeps } else { buzzer is silent }
    The distance sensor reads 12 cm. What happens?
    (a) buzzer is silent (b) buzzer beeps
  21. 21.🤖 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 ON (b) porch lamp OFF
  22. 22.🤖 if (light < 200 AND motion) { porch lamp ON } else { porch lamp OFF }
    The light reading is 400 and motion is detected (true). What happens?
    (a) porch lamp OFF (b) porch lamp ON
  23. 23.🤖 if (light < 200) { lamp ON } else { lamp OFF }
    The light sensor reads 299. What happens?
    (a) lamp OFF (b) lamp ON
  24. 24.🤖 if (light < 400 AND motion) { porch lamp ON } else { porch lamp OFF }
    The light reading is 280 and motion is detected (true). What happens?
    (a) porch lamp OFF (b) porch lamp ON
  25. 25.🤖 if (light < 400 AND motion) { porch lamp ON } else { porch lamp OFF }
    The light reading is 350 and motion is not detected (false). What happens?
    (a) porch lamp ON (b) porch lamp OFF
  26. 26.🤖 if (temperature > 33) { show “Hot” } else if (temperature > 24) { show “Warm” } else { show “Cool” }
    The temperature is 21 °C. What is shown?
    (a) Hot (b) Cool (c) Warm
  27. 27.🤖 if (sound > 80) { red LED ON } else { green LED ON }
    The sound sensor reads 71. What happens?
    (a) red LED ON (b) green LED ON
  28. 28.🤖 if (light < 300 AND motion) { porch lamp ON } else { porch lamp OFF }
    The light reading is 420 and motion is detected (true). What happens?
    (a) porch lamp OFF (b) porch lamp ON
  29. 29.🤖 if (temperature > 34) { show “Hot” } else if (temperature > 21) { show “Warm” } else { show “Cool” }
    The temperature is 40 °C. What is shown?
    (a) Cool (b) Hot (c) Warm
  30. 30.🤖 if (light < 400 OR motion) { porch lamp ON } else { porch lamp OFF }
    The light reading is 280 and motion is detected (true). What happens?
    (a) porch lamp OFF (b) porch lamp ON
  31. 31.🤖 if (moisture < 40) { pump ON } else { pump OFF }
    The soil moisture sensor reads 47 %. What happens?
    (a) pump OFF (b) pump ON
  32. 32.🤖 if (distance < 30) { buzzer beeps } else { buzzer is silent }
    The distance sensor reads 21 cm. What happens?
    (a) buzzer beeps (b) buzzer is silent
  33. 33.🤖 if (light < 400) { lamp ON } else { lamp OFF }
    The light sensor reads 440. What happens?
    (a) lamp OFF (b) lamp ON
  34. 34.🤖 if (light < 300 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
  35. 35.🤖 if (distance < 30) { buzzer beeps } else { buzzer is silent }
    The distance sensor reads 36 cm. What happens?
    (a) buzzer is silent (b) buzzer beeps
  36. 36.🤖 if (light < 400 AND 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
  37. 37.🤖 if (light < 300) { lamp ON } else { lamp OFF }
    The light sensor reads 190. What happens?
    (a) lamp OFF (b) lamp ON
  38. 38.🤖 if (light < 300 OR motion) { porch lamp ON } else { porch lamp OFF }
    The light reading is 140 and motion is detected (true). What happens?
    (a) porch lamp ON (b) porch lamp OFF
  39. 39.🤖 if (light < 200 OR motion) { porch lamp ON } else { porch lamp OFF }
    The light reading is 130 and motion is detected (true). What happens?
    (a) porch lamp ON (b) porch lamp OFF
  40. 40.🤖 if (light < 200 AND motion) { porch lamp ON } else { porch lamp OFF }
    The light reading is 130 and motion is detected (true). What happens?
    (a) porch lamp ON (b) porch lamp OFF

Answer key

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

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