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

App Dev Worksheet: Events

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

Answer key

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

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