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

App Dev Worksheet: Events

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

Answer key

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

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