← if / else: app rules lesson New set →

App Dev Worksheet: If Else Rules

App development lesson 18: if / else: app rules · Set 25 · 40 questions
TalentJR

Developer's tip (Test, then choose): if (test) { A } else { B }: A runs when the test is true, B when it is false. else if: check from the top; the first true test wins and the rest are skipped. >= includes the number itself; > does not. === tests “is equal to”.

NameDateTime takenScore ___ / 40
  1. 1.🔀 What number does this shop app show?
    let total = 730;
    if (total > 500) {
      total = total - 50;
    }
    show(total);
  2. 2.🔀 What does >= mean? (a) not equal (b) less than (c) greater than or equal (d) smaller or equal
  3. 3.🔀 What number does this shop app show?
    let total = 660;
    if (total > 500) {
      total = total - 50;
    }
    show(total);
  4. 4.🔀 What does this battery rule show?
    let battery = 56;
    if (battery < 20) {
      show("Low battery");
    } else {
      show("Battery OK");
    }
    (a) Battery OK (b) Low battery
  5. 5.🔀 Which badge does this quiz app show?
    let marks = 48;
    if (marks >= 80) {
      show("Gold");
    } else if (marks >= 50) {
      show("Silver");
    } else {
      show("Bronze");
    }
    (a) Silver (b) Gold (c) Bronze
  6. 6.🔀 What does this PIN rule show?
    let pin = "29180";
    if (pin.length === 4) {
      show("PIN saved");
    } else {
      show("Use 4 digits");
    }
    (a) PIN saved (b) Use 4 digits
  7. 7.🔀 Which badge does this quiz app show?
    let marks = 62;
    if (marks >= 80) {
      show("Gold");
    } else if (marks >= 50) {
      show("Silver");
    } else {
      show("Bronze");
    }
    (a) Bronze (b) Silver (c) Gold
  8. 8.🔀 When does the else part run? (a) when the test is true (b) never (c) when the test is false (d) always
  9. 9.🔀 In this course’s code, which sign tests “is equal to”? (a) !== (b) => (c) === (d) =
  10. 10.🔀 What does this battery rule show?
    let battery = 9;
    if (battery < 20) {
      show("Low battery");
    } else {
      show("Battery OK");
    }
    (a) Low battery (b) Battery OK
  11. 11.🔀 What does if / else let an app do? (a) repeat forever (b) save a photo (c) pick one of two actions (d) draw a screen
  12. 12.🔀 Which badge does this quiz app show?
    let marks = 96;
    if (marks >= 80) {
      show("Gold");
    } else if (marks >= 50) {
      show("Silver");
    } else {
      show("Bronze");
    }
    (a) Bronze (b) Silver (c) Gold
  13. 13.🔀 Which badge does this quiz app show?
    let marks = 35;
    if (marks >= 80) {
      show("Gold");
    } else if (marks >= 50) {
      show("Silver");
    } else {
      show("Bronze");
    }
    (a) Gold (b) Bronze (c) Silver
  14. 14.🔀 What does this sign-up rule show?
    let age = 12;
    if (age >= 13) {
      show("Welcome!");
    } else {
      show("Ask a parent");
    }
    (a) Ask a parent (b) Welcome!
  15. 15.🔀 What does this PIN rule show?
    let pin = "731";
    if (pin.length === 4) {
      show("PIN saved");
    } else {
      show("Use 4 digits");
    }
    (a) PIN saved (b) Use 4 digits
  16. 16.🔀 What does this PIN rule show?
    let pin = "1769";
    if (pin.length === 4) {
      show("PIN saved");
    } else {
      show("Use 4 digits");
    }
    (a) Use 4 digits (b) PIN saved
  17. 17.🔀 Which badge does this quiz app show?
    let marks = 81;
    if (marks >= 80) {
      show("Gold");
    } else if (marks >= 50) {
      show("Silver");
    } else {
      show("Bronze");
    }
    (a) Gold (b) Silver (c) Bronze
  18. 18.🔀 What does this PIN rule show?
    let pin = "162";
    if (pin.length === 4) {
      show("PIN saved");
    } else {
      show("Use 4 digits");
    }
    (a) Use 4 digits (b) PIN saved
  19. 19.🔀 What does this PIN rule show?
    let pin = "855";
    if (pin.length === 4) {
      show("PIN saved");
    } else {
      show("Use 4 digits");
    }
    (a) PIN saved (b) Use 4 digits
  20. 20.🔀 What does this PIN rule show?
    let pin = "93571";
    if (pin.length === 4) {
      show("PIN saved");
    } else {
      show("Use 4 digits");
    }
    (a) Use 4 digits (b) PIN saved
  21. 21.🔀 What does this battery rule show?
    let battery = 8;
    if (battery < 20) {
      show("Low battery");
    } else {
      show("Battery OK");
    }
    (a) Low battery (b) Battery OK
  22. 22.🔀 Which badge does this quiz app show?
    let marks = 50;
    if (marks >= 80) {
      show("Gold");
    } else if (marks >= 50) {
      show("Silver");
    } else {
      show("Bronze");
    }
    (a) Silver (b) Bronze (c) Gold
  23. 23.🔀 With if / else if / else, how many parts run? (a) only one (b) two (c) all of them (d) none
  24. 24.🔀 What does this battery rule show?
    let battery = 67;
    if (battery < 20) {
      show("Low battery");
    } else {
      show("Battery OK");
    }
    (a) Low battery (b) Battery OK
  25. 25.🔀 Which badge does this quiz app show?
    let marks = 59;
    if (marks >= 80) {
      show("Gold");
    } else if (marks >= 50) {
      show("Silver");
    } else {
      show("Bronze");
    }
    (a) Bronze (b) Gold (c) Silver
  26. 26.🔀 What does this sign-up rule show?
    let age = 13;
    if (age >= 13) {
      show("Welcome!");
    } else {
      show("Ask a parent");
    }
    (a) Ask a parent (b) Welcome!
  27. 27.🔀 What does this sign-up rule show?
    let age = 16;
    if (age >= 13) {
      show("Welcome!");
    } else {
      show("Ask a parent");
    }
    (a) Ask a parent (b) Welcome!
  28. 28.🔀 What does this PIN rule show?
    let pin = "4698";
    if (pin.length === 4) {
      show("PIN saved");
    } else {
      show("Use 4 digits");
    }
    (a) Use 4 digits (b) PIN saved
  29. 29.🔀 Which badge does this quiz app show?
    let marks = 37;
    if (marks >= 80) {
      show("Gold");
    } else if (marks >= 50) {
      show("Silver");
    } else {
      show("Bronze");
    }
    (a) Silver (b) Bronze (c) Gold
  30. 30.🔀 What does this PIN rule show?
    let pin = "5722";
    if (pin.length === 4) {
      show("PIN saved");
    } else {
      show("Use 4 digits");
    }
    (a) Use 4 digits (b) PIN saved
  31. 31.🔀 What does this PIN rule show?
    let pin = "357";
    if (pin.length === 4) {
      show("PIN saved");
    } else {
      show("Use 4 digits");
    }
    (a) PIN saved (b) Use 4 digits
  32. 32.🔀 What does this battery rule show?
    let battery = 10;
    if (battery < 20) {
      show("Low battery");
    } else {
      show("Battery OK");
    }
    (a) Low battery (b) Battery OK
  33. 33.🔀 What does this battery rule show?
    let battery = 37;
    if (battery < 20) {
      show("Low battery");
    } else {
      show("Battery OK");
    }
    (a) Low battery (b) Battery OK
  34. 34.🔀 Which badge does this quiz app show?
    let marks = 82;
    if (marks >= 80) {
      show("Gold");
    } else if (marks >= 50) {
      show("Silver");
    } else {
      show("Bronze");
    }
    (a) Bronze (b) Silver (c) Gold
  35. 35.🔀 What does this PIN rule show?
    let pin = "3998";
    if (pin.length === 4) {
      show("PIN saved");
    } else {
      show("Use 4 digits");
    }
    (a) Use 4 digits (b) PIN saved
  36. 36.🔀 What number does this shop app show?
    let total = 440;
    if (total > 500) {
      total = total - 50;
    }
    show(total);
  37. 37.🔀 What does this sign-up rule show?
    let age = 9;
    if (age >= 13) {
      show("Welcome!");
    } else {
      show("Ask a parent");
    }
    (a) Welcome! (b) Ask a parent
  38. 38.🔀 Which badge does this quiz app show?
    let marks = 67;
    if (marks >= 80) {
      show("Gold");
    } else if (marks >= 50) {
      show("Silver");
    } else {
      show("Bronze");
    }
    (a) Silver (b) Gold (c) Bronze
  39. 39.🔀 What number does this shop app show?
    let total = 370;
    if (total > 500) {
      total = total - 50;
    }
    show(total);
  40. 40.🔀 What does this sign-up rule show?
    let age = 14;
    if (age >= 13) {
      show("Welcome!");
    } else {
      show("Ask a parent");
    }
    (a) Welcome! (b) Ask a parent

Answer key

  1. 680
  2. greater than or equal
  3. 610
  4. Battery OK
  5. Bronze
  6. Use 4 digits
  7. Silver
  8. when the test is false
  9. ===
  10. Low battery
  11. pick one of two actions
  12. Gold
  13. Bronze
  14. Ask a parent
  15. Use 4 digits
  16. PIN saved
  17. Gold
  18. Use 4 digits
  19. Use 4 digits
  20. Use 4 digits
  21. Low battery
  22. Silver
  23. only one
  24. Battery OK
  25. Silver
  26. Welcome!
  27. Welcome!
  28. PIN saved
  29. Bronze
  30. PIN saved
  31. Use 4 digits
  32. Low battery
  33. Battery OK
  34. Gold
  35. PIN saved
  36. 440
  37. Ask a parent
  38. Silver
  39. 370
  40. Welcome!

Free app development lessons, practice and worksheets at talentjr.in/app-development-for-students