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

App Dev Worksheet: Events

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

Answer key

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

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