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

App Dev Worksheet: Events

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

Answer key

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

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