App Dev Worksheet: Events
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.👆 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;
}; - 2.👆 A tap handler runs how many times if the user taps 4 times? (a) 0 (b) 4 (c) 8 (d) 1
-
3.👆 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, nameBox.text! (b) Kabir (c) Well done! (d) Well done, Kabir! - 4.True or false: the user taps Play is a tap event. (a) False (b) True
-
5.👆 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! (b) Arjun (c) Hi, Arjun! (d) Hi, nameBox.text! -
6.👆 The user taps the button 3 times. What number does the label show now?
let coins = 6;
button.onTap = function () {
coins = coins + 4;
label.text = coins;
}; -
7.👆 The user taps the button 5 times. What number does the label show now?
let points = 1;
button.onTap = function () {
points = points + 2;
label.text = points;
}; -
8.👆 The user taps the button 3 times. What number does the label show now?
let likes = 0;
button.onTap = function () {
if (likes < 3) {
likes = likes + 1;
}
label.text = likes;
}; - 9.True or false: the screen first opens is a load event. (a) False (b) True
-
10.👆 The user taps the button 6 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 -
11.👆 The user types Kabir in nameBox and taps the button 1 time. What does the label show?
button.onTap = function () {
label.text = "Hi, " + nameBox.text + "!";
}; (a) Hi, Kabir! (b) Kabir (c) Hi, nameBox.text! (d) Hi! -
12.👆 The user types Riya 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, Riya! (b) Riya (c) Well done, nameBox.text! (d) Well done! -
13.👆 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, Riya! (b) Hi, nameBox.text! (c) Riya (d) Hi! -
14.👆 The user taps the button 6 times. What number does the label show now?
let coins = 8;
button.onTap = function () {
coins = coins + 2;
label.text = coins;
}; - 15.👆 What kind of event is this: the user types a letter? (a) a timer event (b) a load event (c) a tap event (d) a text event
- 16.👆 What kind of event is this: a finger hits Like? (a) a timer event (b) a tap event (c) a load event (d) a text event
-
17.👆 The user taps the button 2 times. What number does the label show now?
let coins = 10;
button.onTap = function () {
coins = coins + 2;
label.text = coins;
}; -
18.👆 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) OFF (b) ON -
19.👆 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) Well done! (b) Aman (c) Well done, nameBox.text! (d) Well done, Aman! - 20.👆 What kind of event is this: the user taps Play? (a) a load event (b) a tap event (c) a text event (d) a timer event
-
21.👆 The user taps the button 5 times. What number does the label show now?
let score = 10;
button.onTap = function () {
score = score + 1;
label.text = score;
}; - 22.True or false: the screen first opens is a text event. (a) True (b) False
-
23.👆 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;
}; - 24.True or false: the user taps Play is a timer event. (a) False (b) True
-
25.👆 The user taps the button 2 times. What number does the label show now?
let coins = 6;
button.onTap = function () {
coins = coins + 2;
label.text = coins;
}; -
26.👆 The user taps the button 6 times. What number does the label show now?
let likes = 0;
button.onTap = function () {
if (likes < 4) {
likes = likes + 1;
}
label.text = likes;
}; -
27.👆 The user taps the button 3 times. What number does the label show now?
let coins = 3;
button.onTap = function () {
coins = coins + 1;
label.text = coins;
}; - 28.👆 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
-
29.👆 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;
}; - 30.👆 “On tap → do this” links an event to ___. (a) a font (b) a charger (c) an action (d) a web address
- 31.👆 What kind of event is this: a 5-minute alarm ends? (a) a tap event (b) a load event (c) a timer event (d) a text event
- 32.👆 What kind of event is this: the search box changes? (a) a tap event (b) a timer event (c) a load event (d) a text event
-
33.👆 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;
}; - 34.👆 What kind of event is this: the screen first opens? (a) a load event (b) a tap event (c) a text event (d) a timer event
-
35.👆 The user taps the button 4 times. What number does the label show now?
let likes = 0;
button.onTap = function () {
if (likes < 5) {
likes = likes + 1;
}
label.text = likes;
}; - 36.👆 An event in an app is ___. (a) a kind of list (b) something that happens (c) an app store (d) a colour theme
- 37.True or false: a finger hits Like is a timer event. (a) False (b) True
- 38.True or false: the search box changes is a text event. (a) False (b) True
-
39.👆 The user taps the button 2 times. What number does the label show now?
let likes = 0;
button.onTap = function () {
if (likes < 4) {
likes = likes + 1;
}
label.text = likes;
}; -
40.👆 The user taps the button 3 times. What number does the label show now?
let stars = 6;
button.onTap = function () {
stars = stars + 1;
label.text = stars;
};
Answer key
- 2
- 4
- Well done, Kabir!
- True
- Hi, Arjun!
- 18
- 11
- 3
- True
- OFF
- Hi, Kabir!
- Well done, Riya!
- Hi, Riya!
- 20
- a text event
- a tap event
- 14
- ON
- Well done, Aman!
- a tap event
- 15
- False
- 1
- False
- 10
- 4
- 6
- a timer event
- 2
- an action
- a timer event
- a text event
- 1
- a load event
- 4
- something that happens
- False
- True
- 2
- 9
Free app development lessons, practice and worksheets at talentjr.in/app-development-for-students