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

App Dev Worksheet: Events

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

Answer key

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

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