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

App Dev Worksheet: Events

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

Answer key

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

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