← Events: on tap, do this lesson New set →

App Dev Worksheet: Events

App development lesson 17: Events: on tap, do this · Set 130 · 40 questions
TalentJR

Developer's tip (When this, do that): Event → handler → action: “on tap, do this”. The handler runs once for every tap. Counter: start + taps × step. A limit stops it growing; on = !on flips ON / OFF.

NameDateTime takenScore ___ / 40
  1. 1.👆 The user taps the button 5 times. What number does the label show now?
    let likes = 0;
    button.onTap = function () {
      if (likes < 2) {
        likes = likes + 1;
      }
      label.text = likes;
    };
  2. 2.👆 What kind of event is this: a countdown hits zero? (a) a text event (b) a timer event (c) a tap event (d) a load event
  3. 3.👆 The user taps the button 1 times. What number does the label show now?
    let likes = 0;
    button.onTap = function () {
      if (likes < 3) {
        likes = likes + 1;
      }
      label.text = likes;
    };
  4. 4.True or false: the screen first opens is a tap event. (a) True (b) False
  5. 5.👆 The user taps the button 5 times. What does the label show now?
    let on = false;
    button.onTap = function () {
      on = !on;
      if (on) {
        label.text = "ON";
      } else {
        label.text = "OFF";
      }
    };
    (a) OFF (b) ON
  6. 6.👆 The user taps the button 1 times. What number does the label show now?
    let likes = 0;
    button.onTap = function () {
      if (likes < 4) {
        likes = likes + 1;
      }
      label.text = likes;
    };
  7. 7.👆 A tap handler runs how many times if the user taps 4 times? (a) 8 (b) 4 (c) 0 (d) 1
  8. 8.👆 “On tap → do this” links an event to ___. (a) a web address (b) an action (c) a charger (d) a font
  9. 9.👆 The user taps the button 6 times. What number does the label show now?
    let lives = 2;
    button.onTap = function () {
      lives = lives + 5;
      label.text = lives;
    };
  10. 10.👆 An event in an app is ___. (a) a kind of list (b) a colour theme (c) an app store (d) something that happens
  11. 11.True or false: a 5-minute alarm ends is a text event. (a) False (b) True
  12. 12.👆 The user taps the button 5 times. What number does the label show now?
    let likes = 0;
    button.onTap = function () {
      if (likes < 4) {
        likes = likes + 1;
      }
      label.text = likes;
    };
  13. 13.True or false: the user taps Play is a tap event. (a) False (b) True
  14. 14.👆 What kind of event is this: the user presses Save? (a) a tap event (b) a load event (c) a text event (d) a timer event
  15. 15.👆 The user taps the button 5 times. What number does the label show now?
    let coins = 4;
    button.onTap = function () {
      coins = coins + 3;
      label.text = coins;
    };
  16. 16.👆 The user taps the button 6 times. What number does the label show now?
    let likes = 0;
    button.onTap = function () {
      if (likes < 3) {
        likes = likes + 1;
      }
      label.text = likes;
    };
  17. 17.👆 The user taps the button 2 times. What does the label show now?
    let on = false;
    button.onTap = function () {
      on = !on;
      if (on) {
        label.text = "ON";
      } else {
        label.text = "OFF";
      }
    };
    (a) ON (b) OFF
  18. 18.👆 The user types Kabir in nameBox and taps the button 1 time. What does the label show?
    button.onTap = function () {
      label.text = "Hi, " + nameBox.text + "!";
    };
    (a) Hi, Kabir! (b) Hi, nameBox.text! (c) Kabir (d) Hi!
  19. 19.👆 The user taps the button 6 times. What does the label show now?
    let on = false;
    button.onTap = function () {
      on = !on;
      if (on) {
        label.text = "ON";
      } else {
        label.text = "OFF";
      }
    };
    (a) ON (b) OFF
  20. 20.👆 What kind of event is this: the user taps Play? (a) a timer event (b) a tap event (c) a load event (d) a text event
  21. 21.👆 The user types Zoya in nameBox and taps the button 1 time. What does the label show?
    button.onTap = function () {
      label.text = "Hello, " + nameBox.text + "!";
    };
    (a) Hello, nameBox.text! (b) Zoya (c) Hello! (d) Hello, Zoya!
  22. 22.👆 The user taps the button 1 times. What does the label show now?
    let on = false;
    button.onTap = function () {
      on = !on;
      if (on) {
        label.text = "ON";
      } else {
        label.text = "OFF";
      }
    };
    (a) ON (b) OFF
  23. 23.True or false: a 5-minute alarm ends is a tap event. (a) True (b) False
  24. 24.👆 What kind of event is this: a 5-minute alarm ends? (a) a timer event (b) a text event (c) a load event (d) a tap event
  25. 25.👆 The user types Aman in nameBox and taps the button 1 time. What does the label show?
    button.onTap = function () {
      label.text = "Hi, " + nameBox.text + "!";
    };
    (a) Hi! (b) Aman (c) Hi, nameBox.text! (d) Hi, Aman!
  26. 26.True or false: a finger hits Like is a tap event. (a) True (b) False
  27. 27.True or false: the user presses Save is a tap event. (a) False (b) True
  28. 28.👆 The user taps the button 7 times. What does the label show now?
    let on = false;
    button.onTap = function () {
      on = !on;
      if (on) {
        label.text = "ON";
      } else {
        label.text = "OFF";
      }
    };
    (a) OFF (b) ON
  29. 29.👆 What kind of event is this: the user types a letter? (a) a timer event (b) a load event (c) a tap event (d) a text event
  30. 30.👆 The user taps the button 3 times. What number does the label show now?
    let points = 1;
    button.onTap = function () {
      points = points + 3;
      label.text = points;
    };
  31. 31.True or false: the user presses Save is a timer event. (a) True (b) False
  32. 32.True or false: the user taps Play is a timer event. (a) True (b) False
  33. 33.👆 The user taps the button 6 times. What number does the label show now?
    let points = 6;
    button.onTap = function () {
      points = points + 5;
      label.text = points;
    };
  34. 34.👆 The user taps the button 4 times. What number does the label show now?
    let coins = 0;
    button.onTap = function () {
      coins = coins + 1;
      label.text = coins;
    };
  35. 35.👆 The user types Kabir in nameBox and taps the button 1 time. What does the label show?
    button.onTap = function () {
      label.text = "Welcome, " + nameBox.text + "!";
    };
    (a) Welcome! (b) Welcome, nameBox.text! (c) Welcome, Kabir! (d) Kabir
  36. 36.👆 The user taps the button 5 times. What number does the label show now?
    let lives = 2;
    button.onTap = function () {
      lives = lives + 2;
      label.text = lives;
    };
  37. 37.True or false: the user types a letter is a tap event. (a) False (b) True
  38. 38.👆 The user types Aman in nameBox and taps the button 1 time. What does the label show?
    button.onTap = function () {
      label.text = "Hello, " + nameBox.text + "!";
    };
    (a) Hello, nameBox.text! (b) Aman (c) Hello! (d) Hello, Aman!
  39. 39.👆 The user taps the button 6 times. What number does the label show now?
    let lives = 4;
    button.onTap = function () {
      lives = lives + 4;
      label.text = lives;
    };
  40. 40.👆 The user types Kabir in nameBox and taps the button 1 time. What does the label show?
    button.onTap = function () {
      label.text = "Well done, " + nameBox.text + "!";
    };
    (a) Well done, nameBox.text! (b) Well done, Kabir! (c) Kabir (d) Well done!

Answer key

  1. 2
  2. a timer event
  3. 1
  4. False
  5. ON
  6. 1
  7. 4
  8. an action
  9. 32
  10. something that happens
  11. False
  12. 4
  13. True
  14. a tap event
  15. 19
  16. 3
  17. OFF
  18. Hi, Kabir!
  19. OFF
  20. a tap event
  21. Hello, Zoya!
  22. ON
  23. False
  24. a timer event
  25. Hi, Aman!
  26. True
  27. True
  28. ON
  29. a text event
  30. 10
  31. False
  32. False
  33. 36
  34. 4
  35. Welcome, Kabir!
  36. 12
  37. False
  38. Hello, Aman!
  39. 28
  40. Well done, Kabir!

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