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

App Dev Worksheet: Events

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

Answer key

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

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