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

App Dev Worksheet: Events

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

Answer key

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

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