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

App Dev Worksheet: Events

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

Answer key

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

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