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

App Dev Worksheet: Events

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

Answer key

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

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