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

App Dev Worksheet: Events

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

Answer key

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

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