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

App Dev Worksheet: Events

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

Answer key

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

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