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

App Dev Worksheet: Events

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

Answer key

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

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