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

App Dev Worksheet: Events

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

Answer key

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

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