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

App Dev Worksheet: Events

App development lesson 17: Events: on tap, do this · Set 248 · 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.👆 “On tap → do this” links an event to ___. (a) a charger (b) a font (c) a web address (d) an action
  2. 2.True or false: the user types a letter is a load event. (a) True (b) False
  3. 3.👆 The user taps the button 6 times. What number does the label show now?
    let score = 4;
    button.onTap = function () {
      score = score + 3;
      label.text = score;
    };
  4. 4.👆 What kind of event is this: a finger hits Like? (a) a text event (b) a load event (c) a tap event (d) a timer event
  5. 5.True or false: the user presses Save is a load event. (a) True (b) False
  6. 6.👆 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) OFF (b) ON
  7. 7.👆 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
  8. 8.👆 The user taps the button 7 times. What number does the label show now?
    let likes = 0;
    button.onTap = function () {
      if (likes < 5) {
        likes = likes + 1;
      }
      label.text = likes;
    };
  9. 9.👆 The user taps the button 3 times. What number does the label show now?
    let points = 5;
    button.onTap = function () {
      points = points + 3;
      label.text = points;
    };
  10. 10.👆 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) ON (b) OFF
  11. 11.True or false: the screen first opens is a load event. (a) True (b) False
  12. 12.👆 The user taps the button 5 times. What number does the label show now?
    let lives = 8;
    button.onTap = function () {
      lives = lives + 3;
      label.text = lives;
    };
  13. 13.👆 The user taps the button 2 times. What number does the label show now?
    let coins = 6;
    button.onTap = function () {
      coins = coins + 3;
      label.text = coins;
    };
  14. 14.👆 What kind of event is this: the screen first opens? (a) a load event (b) a tap event (c) a timer event (d) a text event
  15. 15.👆 What kind of event is this: the user types a letter? (a) a load event (b) a text event (c) a timer event (d) a tap event
  16. 16.👆 The user taps the button 3 times. What number does the label show now?
    let coins = 2;
    button.onTap = function () {
      coins = coins + 1;
      label.text = coins;
    };
  17. 17.👆 The user taps the button 6 times. What number does the label show now?
    let points = 1;
    button.onTap = function () {
      points = points + 1;
      label.text = points;
    };
  18. 18.👆 The user taps the button 5 times. What number does the label show now?
    let likes = 0;
    button.onTap = function () {
      if (likes < 5) {
        likes = likes + 1;
      }
      label.text = likes;
    };
  19. 19.👆 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
  20. 20.👆 Code that runs when an event happens is called a ___. (a) headline (b) hashtag (c) handler (d) header
  21. 21.👆 An event in an app is ___. (a) a colour theme (b) something that happens (c) a kind of list (d) an app store
  22. 22.👆 A tap handler runs how many times if the user taps 4 times? (a) 1 (b) 4 (c) 8 (d) 0
  23. 23.👆 The user taps the button 4 times. What number does the label show now?
    let points = 9;
    button.onTap = function () {
      points = points + 5;
      label.text = points;
    };
  24. 24.👆 The user taps the button 6 times. What number does the label show now?
    let likes = 0;
    button.onTap = function () {
      if (likes < 4) {
        likes = likes + 1;
      }
      label.text = likes;
    };
  25. 25.👆 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! (b) Well done, nameBox.text! (c) Kabir (d) Well done, Kabir!
  26. 26.👆 The user taps the button 6 times. What number does the label show now?
    let coins = 4;
    button.onTap = function () {
      coins = coins + 3;
      label.text = coins;
    };
  27. 27.True or false: the search box changes is a timer event. (a) False (b) True
  28. 28.👆 The user taps the button 4 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
  29. 29.👆 The user taps the button 3 times. What number does the label show now?
    let lives = 6;
    button.onTap = function () {
      lives = lives + 5;
      label.text = lives;
    };
  30. 30.True or false: a countdown hits zero is a tap event. (a) False (b) True
  31. 31.👆 The user taps the button 3 times. What number does the label show now?
    let coins = 8;
    button.onTap = function () {
      coins = coins + 2;
      label.text = coins;
    };
  32. 32.True or false: the app starts up is a load event. (a) False (b) True
  33. 33.👆 The user taps the button 4 times. What number does the label show now?
    let likes = 0;
    button.onTap = function () {
      if (likes < 2) {
        likes = likes + 1;
      }
      label.text = likes;
    };
  34. 34.👆 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) ON (b) OFF
  35. 35.True or false: a finger hits Like is a tap event. (a) False (b) True
  36. 36.👆 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!
  37. 37.👆 The user taps the button 3 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
  38. 38.True or false: the user presses Save is a tap event. (a) False (b) True
  39. 39.True or false: the screen first opens is a text event. (a) False (b) True
  40. 40.👆 Which of these is an event? (a) the font size (b) the icon colour (c) a list of names (d) the user taps a button

Answer key

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

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