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

App Dev Worksheet: Events

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

Answer key

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

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