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

App Dev Worksheet: Events

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

Answer key

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

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