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

App Dev Worksheet: Events

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

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