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

App Dev Worksheet: Events

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

Answer key

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

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