← If / else with sensors lesson New set →

Electronics Worksheet: If Else with Sensors

Electronics lesson 24: If / else with sensors · Set 322 · 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 > 25) { fan ON } else { fan OFF }
    The temperature sensor reads 25 °C. What happens?
    (a) fan OFF (b) fan ON
  2. 2.🤖 if (temperature > 25) { fan ON } else { fan OFF }
    The temperature sensor reads 22 °C. What happens?
    (a) fan ON (b) fan OFF
  3. 3.🤖 “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
  4. 4.🤖 if (temperature > 31) { show “Hot” } else if (temperature > 18) { show “Warm” } else { show “Cool” }
    The temperature is 30 °C. What is shown?
    (a) Warm (b) Cool (c) Hot
  5. 5.🤖 if (temperature > 30) { show “Hot” } else if (temperature > 19) { show “Warm” } else { show “Cool” }
    The temperature is 26 °C. What is shown?
    (a) Cool (b) Hot (c) Warm
  6. 6.🤖 if (light < 200 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
  7. 7.🤖 In “if (temp > 30)”, what runs when temp is exactly 30? (a) neither part (b) the if part (c) the else part (d) both parts
  8. 8.🤖 if (light < 300 AND motion) { porch lamp ON } else { porch lamp OFF }
    The light reading is 480 and motion is not detected (false). What happens?
    (a) porch lamp OFF (b) porch lamp ON
  9. 9.🤖 if (light < 500) { lamp ON } else { lamp OFF }
    The light sensor reads 637. What happens?
    (a) lamp ON (b) lamp OFF
  10. 10.🤖 if (light < 400 OR motion) { porch lamp ON } else { porch lamp OFF }
    The light reading is 330 and motion is not detected (false). What happens?
    (a) porch lamp ON (b) porch lamp OFF
  11. 11.🤖 if (light < 200 AND motion) { porch lamp ON } else { porch lamp OFF }
    The light reading is 170 and motion is detected (true). What happens?
    (a) porch lamp ON (b) porch lamp OFF
  12. 12.🤖 if (temperature > 31) { show “Hot” } else if (temperature > 19) { show “Warm” } else { show “Cool” }
    The temperature is 40 °C. What is shown?
    (a) Hot (b) Cool (c) Warm
  13. 13.🤖 if (light < 400 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
  14. 14.🤖 if (temperature > 35) { show “Hot” } else if (temperature > 24) { show “Warm” } else { show “Cool” }
    The temperature is 13 °C. What is shown?
    (a) Hot (b) Cool (c) Warm
  15. 15.🤖 if (temperature > 31) { show “Hot” } else if (temperature > 24) { show “Warm” } else { show “Cool” }
    The temperature is 19 °C. What is shown?
    (a) Cool (b) Warm (c) Hot
  16. 16.🤖 if (light < 200 OR motion) { porch lamp ON } else { porch lamp OFF }
    The light reading is 280 and motion is detected (true). What happens?
    (a) porch lamp ON (b) porch lamp OFF
  17. 17.🤖 if (moisture < 50) { pump ON } else { pump OFF }
    The soil moisture sensor reads 32 %. What happens?
    (a) pump OFF (b) pump ON
  18. 18.🤖 if (light < 200 OR motion) { porch lamp ON } else { porch lamp OFF }
    The light reading is 420 and motion is not detected (false). What happens?
    (a) porch lamp OFF (b) porch lamp ON
  19. 19.🤖 if (light < 200 AND 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 (moisture < 50) { pump ON } else { pump OFF }
    The soil moisture sensor reads 61 %. What happens?
    (a) pump OFF (b) pump ON
  21. 21.🤖 if (temperature > 30) { show “Hot” } else if (temperature > 24) { show “Warm” } else { show “Cool” }
    The temperature is 31 °C. What is shown?
    (a) Warm (b) Cool (c) Hot
  22. 22.🤖 if (temperature > 25) { fan ON } else { fan OFF }
    The temperature sensor reads 27 °C. What happens?
    (a) fan OFF (b) fan ON
  23. 23.🤖 if (distance < 30) { buzzer beeps } else { buzzer is silent }
    The distance sensor reads 38 cm. What happens?
    (a) buzzer is silent (b) buzzer beeps
  24. 24.🤖 if (temperature > 34) { show “Hot” } else if (temperature > 24) { show “Warm” } else { show “Cool” }
    The temperature is 12 °C. What is shown?
    (a) Warm (b) Cool (c) Hot
  25. 25.🤖 if (temperature > 30) { fan ON } else { fan OFF }
    The temperature sensor reads 25 °C. What happens?
    (a) fan ON (b) fan OFF
  26. 26.🤖 if (sound > 60) { red LED ON } else { green LED ON }
    The sound sensor reads 50. What happens?
    (a) red LED ON (b) green LED ON
  27. 27.🤖 if (temperature > 30) { show “Hot” } else if (temperature > 20) { show “Warm” } else { show “Cool” }
    The temperature is 11 °C. What is shown?
    (a) Warm (b) Cool (c) Hot
  28. 28.🤖 if (temperature > 34) { show “Hot” } else if (temperature > 19) { show “Warm” } else { show “Cool” }
    The temperature is 44 °C. What is shown?
    (a) Hot (b) Warm (c) Cool
  29. 29.🤖 if (light < 200 OR motion) { porch lamp ON } else { porch lamp OFF }
    The light reading is 590 and motion is not detected (false). What happens?
    (a) porch lamp ON (b) porch lamp OFF
  30. 30.🤖 if (moisture < 30) { pump ON } else { pump OFF }
    The soil moisture sensor reads 10 %. What happens?
    (a) pump ON (b) pump OFF
  31. 31.🤖 if (distance < 10) { buzzer beeps } else { buzzer is silent }
    The distance sensor reads 16 cm. What happens?
    (a) buzzer beeps (b) buzzer is silent
  32. 32.🤖 if (temperature > 32) { show “Hot” } else if (temperature > 20) { show “Warm” } else { show “Cool” }
    The temperature is 19 °C. What is shown?
    (a) Hot (b) Cool (c) Warm
  33. 33.🤖 if (moisture < 30) { pump ON } else { pump OFF }
    The soil moisture sensor reads 39 %. What happens?
    (a) pump OFF (b) pump ON
  34. 34.🤖 if (light < 200 OR 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
  35. 35.🤖 if (distance < 15) { buzzer beeps } else { buzzer is silent }
    The distance sensor reads 19 cm. What happens?
    (a) buzzer beeps (b) buzzer is silent
  36. 36.🤖 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
  37. 37.🤖 if (light < 200 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 ON (b) porch lamp OFF
  38. 38.🤖 if (temperature > 32) { fan ON } else { fan OFF }
    The temperature sensor reads 39 °C. What happens?
    (a) fan OFF (b) fan ON
  39. 39.🤖 if (light < 300) { lamp ON } else { lamp OFF }
    The light sensor reads 392. What happens?
    (a) lamp OFF (b) lamp ON
  40. 40.🤖 if (temperature > 28) { fan ON } else { fan OFF }
    The temperature sensor reads 31 °C. What happens?
    (a) fan ON (b) fan OFF

Answer key

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

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