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

App Dev Worksheet: Events

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

Answer key

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

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