← If / else with sensors lesson New set →

Electronics Worksheet: If Else with Sensors

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

Answer key

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

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