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

App Dev Worksheet: Events

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

Answer key

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

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