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

App Dev Worksheet: Events

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

Answer key

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

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