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

App Dev Worksheet: Events

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

Answer key

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

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