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

App Dev Worksheet: Events

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

Answer key

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

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