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

App Dev Worksheet: Events

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

Answer key

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

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