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

App Dev Worksheet: Events

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

Answer key

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

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