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

App Dev Worksheet: Events

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

Answer key

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

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