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

App Dev Worksheet: Events

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

Answer key

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

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