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

App Dev Worksheet: Events

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

Answer key

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

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