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

App Dev Worksheet: Events

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

Answer key

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

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