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

App Dev Worksheet: Events

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

Answer key

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

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