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

App Dev Worksheet: Events

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

Answer key

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

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