← If / else with sensors lesson New set →

Electronics Worksheet: If Else with Sensors

Electronics lesson 24: If / else with sensors · Set 35 · 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 (temperature > 30) { fan ON } else { fan OFF }
    The temperature sensor reads 29 °C. What happens?
    (a) fan ON (b) fan OFF
  2. 2.🤖 if (temperature > 25) { fan ON } else { fan OFF }
    The temperature sensor reads 31 °C. What happens?
    (a) fan ON (b) fan OFF
  3. 3.🤖 if (temperature > 25) { fan ON } else { fan OFF }
    The temperature sensor reads 29 °C. What happens?
    (a) fan OFF (b) fan ON
  4. 4.🤖 if (light < 300 OR motion) { porch lamp ON } else { porch lamp OFF }
    The light reading is 550 and motion is not detected (false). What happens?
    (a) porch lamp ON (b) porch lamp OFF
  5. 5.🤖 if (temperature > 31) { show “Hot” } else if (temperature > 20) { show “Warm” } else { show “Cool” }
    The temperature is 36 °C. What is shown?
    (a) Warm (b) Cool (c) Hot
  6. 6.🤖 “if (A AND B)” is true when … (a) only B is true (b) both A and B are true (c) both are false (d) only A is true
  7. 7.🤖 if (distance < 10) { buzzer beeps } else { buzzer is silent }
    The distance sensor reads 8 cm. What happens?
    (a) buzzer beeps (b) buzzer is silent
  8. 8.🤖 if (moisture < 30) { pump ON } else { pump OFF }
    The soil moisture sensor reads 44 %. What happens?
    (a) pump OFF (b) pump ON
  9. 9.🤖 if (light < 200) { lamp ON } else { lamp OFF }
    The light sensor reads 307. What happens?
    (a) lamp ON (b) lamp OFF
  10. 10.🤖 In “if (temp > 30)”, what runs when temp is exactly 30? (a) the if part (b) both parts (c) neither part (d) the else part
  11. 11.🤖 if (temperature > 35) { show “Hot” } else if (temperature > 21) { show “Warm” } else { show “Cool” }
    The temperature is 30 °C. What is shown?
    (a) Warm (b) Cool (c) Hot
  12. 12.🤖 if (temperature > 25) { fan ON } else { fan OFF }
    The temperature sensor reads 28 °C. What happens?
    (a) fan OFF (b) fan ON
  13. 13.🤖 if (distance < 15) { buzzer beeps } else { buzzer is silent }
    The distance sensor reads 11 cm. What happens?
    (a) buzzer beeps (b) buzzer is silent
  14. 14.🤖 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
  15. 15.🤖 if (light < 300 AND motion) { porch lamp ON } else { porch lamp OFF }
    The light reading is 310 and motion is not detected (false). What happens?
    (a) porch lamp ON (b) porch lamp OFF
  16. 16.🤖 if (temperature > 37) { show “Hot” } else if (temperature > 21) { show “Warm” } else { show “Cool” }
    The temperature is 31 °C. What is shown?
    (a) Warm (b) Cool (c) Hot
  17. 17.🤖 if (temperature > 31) { show “Hot” } else if (temperature > 18) { show “Warm” } else { show “Cool” }
    The temperature is 39 °C. What is shown?
    (a) Hot (b) Cool (c) Warm
  18. 18.🤖 if (temperature > 38) { show “Hot” } else if (temperature > 25) { show “Warm” } else { show “Cool” }
    The temperature is 11 °C. What is shown?
    (a) Cool (b) Hot (c) Warm
  19. 19.🤖 if (distance < 10) { buzzer beeps } else { buzzer is silent }
    The distance sensor reads 10 cm. What happens?
    (a) buzzer is silent (b) buzzer beeps
  20. 20.🤖 if (light < 400 OR motion) { porch lamp ON } else { porch lamp OFF }
    The light reading is 630 and motion is detected (true). What happens?
    (a) porch lamp ON (b) porch lamp OFF
  21. 21.🤖 if (temperature > 35) { show “Hot” } else if (temperature > 18) { show “Warm” } else { show “Cool” }
    The temperature is 34 °C. What is shown?
    (a) Hot (b) Cool (c) Warm
  22. 22.🤖 if (light < 300 AND motion) { porch lamp ON } else { porch lamp OFF }
    The light reading is 130 and motion is not detected (false). What happens?
    (a) porch lamp OFF (b) porch lamp ON
  23. 23.🤖 if (moisture < 30) { pump ON } else { pump OFF }
    The soil moisture sensor reads 12 %. What happens?
    (a) pump ON (b) pump OFF
  24. 24.🤖 if (light < 300 AND motion) { porch lamp ON } else { porch lamp OFF }
    The light reading is 560 and motion is not detected (false). What happens?
    (a) porch lamp OFF (b) porch lamp ON
  25. 25.🤖 if (distance < 20) { buzzer beeps } else { buzzer is silent }
    The distance sensor reads 27 cm. What happens?
    (a) buzzer is silent (b) buzzer beeps
  26. 26.🤖 if (light < 300) { lamp ON } else { lamp OFF }
    The light sensor reads 435. What happens?
    (a) lamp ON (b) lamp OFF
  27. 27.🤖 if (light < 400 AND motion) { porch lamp ON } else { porch lamp OFF }
    The light reading is 520 and motion is not detected (false). What happens?
    (a) porch lamp OFF (b) porch lamp ON
  28. 28.🤖 if (distance < 10) { buzzer beeps } else { buzzer is silent }
    The distance sensor reads 2 cm. What happens?
    (a) buzzer beeps (b) buzzer is silent
  29. 29.🤖 if (light < 200) { lamp ON } else { lamp OFF }
    The light sensor reads 104. What happens?
    (a) lamp OFF (b) lamp ON
  30. 30.🤖 if (temperature > 33) { show “Hot” } else if (temperature > 26) { show “Warm” } else { show “Cool” }
    The temperature is 13 °C. What is shown?
    (a) Cool (b) Warm (c) Hot
  31. 31.🤖 if (temperature > 31) { show “Hot” } else if (temperature > 20) { show “Warm” } else { show “Cool” }
    The temperature is 16 °C. What is shown?
    (a) Cool (b) Hot (c) Warm
  32. 32.🤖 if (distance < 15) { buzzer beeps } else { buzzer is silent }
    The distance sensor reads 8 cm. What happens?
    (a) buzzer is silent (b) buzzer beeps
  33. 33.🤖 if (temperature > 33) { show “Hot” } else if (temperature > 18) { show “Warm” } else { show “Cool” }
    The temperature is 44 °C. What is shown?
    (a) Warm (b) Hot (c) Cool
  34. 34.🤖 if (light < 200 AND motion) { porch lamp ON } else { porch lamp OFF }
    The light reading is 260 and motion is detected (true). What happens?
    (a) porch lamp ON (b) porch lamp OFF
  35. 35.🤖 if (temperature > 35) { 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
  36. 36.🤖 if (temperature > 30) { fan ON } else { fan OFF }
    The temperature sensor reads 37 °C. What happens?
    (a) fan ON (b) fan OFF
  37. 37.🤖 if (temperature > 34) { show “Hot” } else if (temperature > 22) { show “Warm” } else { show “Cool” }
    The temperature is 37 °C. What is shown?
    (a) Warm (b) Hot (c) Cool
  38. 38.🤖 if (temperature > 34) { show “Hot” } else if (temperature > 23) { show “Warm” } else { show “Cool” }
    The temperature is 39 °C. What is shown?
    (a) Warm (b) Hot (c) Cool
  39. 39.🤖 if (temperature > 37) { show “Hot” } else if (temperature > 26) { show “Warm” } else { show “Cool” }
    The temperature is 18 °C. What is shown?
    (a) Cool (b) Hot (c) Warm
  40. 40.🤖 if (temperature > 34) { show “Hot” } else if (temperature > 20) { show “Warm” } else { show “Cool” }
    The temperature is 36 °C. What is shown?
    (a) Warm (b) Cool (c) Hot

Answer key

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

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