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

App Dev Worksheet: Events

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

Answer key

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

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