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

App Dev Worksheet: Events

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

Answer key

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

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