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