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.👆 What kind of event is this: a finger hits Like? (a) a text event (b) a load event (c) a tap event (d) a timer event
- 3.👆 What kind of event is this: the search box changes? (a) a load event (b) a text event (c) a timer event (d) a tap event
- 4.👆 What kind of event is this: the screen first opens? (a) a tap event (b) a timer event (c) a load event (d) a text event
-
5.👆 The user taps the button 3 times. What number does the label show now?
let score = 6;
button.onTap = function () {
score = score + 2;
label.text = score;
}; - 6.True or false: the app starts up is a text event. (a) True (b) False
-
7.👆 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) Meera (c) Hi! (d) Hi, Meera! - 8.👆 An event in an app is ___. (a) a kind of list (b) something that happens (c) an app store (d) a colour theme
-
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.👆 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;
}; - 11.👆 Code that runs when an event happens is called a ___. (a) headline (b) handler (c) hashtag (d) header
- 12.👆 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
- 13.True or false: a 5-minute alarm ends is a load event. (a) False (b) True
-
14.👆 The user taps the button 4 times. What number does the label show now?
let stars = 2;
button.onTap = function () {
stars = stars + 2;
label.text = stars;
}; -
15.👆 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) ON (b) OFF -
16.👆 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, nameBox.text! (b) Riya (c) Hi! (d) Hi, Riya! -
17.👆 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 -
18.👆 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) Arjun (b) Hi, nameBox.text! (c) Hi! (d) Hi, Arjun! - 19.True or false: one second passes is a timer event. (a) False (b) True
- 20.True or false: a countdown hits zero is a tap event. (a) True (b) False
-
21.👆 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! (b) Welcome, Meera! (c) Meera (d) Welcome, nameBox.text! -
22.👆 The user taps the button 7 times. What number does the label show now?
let likes = 0;
button.onTap = function () {
if (likes < 2) {
likes = likes + 1;
}
label.text = likes;
}; -
23.👆 The user taps the button 2 times. What number does the label show now?
let score = 0;
button.onTap = function () {
score = score + 3;
label.text = score;
}; - 24.👆 Which of these is an event? (a) the icon colour (b) a list of names (c) the user taps a button (d) the font size
- 25.👆 What kind of event is this: a countdown hits zero? (a) a text event (b) a timer event (c) a tap event (d) a load event
- 26.True or false: the user presses Save is a text event. (a) False (b) True
- 27.True or false: a 5-minute alarm ends is a timer event. (a) False (b) True
-
28.👆 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) Hello, nameBox.text! (b) Hello, Arjun! (c) Hello! (d) Arjun -
29.👆 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) OFF (b) ON -
30.👆 The user taps the button 3 times. What number does the label show now?
let points = 0;
button.onTap = function () {
points = points + 3;
label.text = points;
}; -
31.👆 The user taps the button 6 times. What number does the label show now?
let score = 9;
button.onTap = function () {
score = score + 4;
label.text = score;
}; -
32.👆 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) ON (b) OFF - 33.True or false: the search box changes is a text event. (a) False (b) True
-
34.👆 The user taps the button 2 times. What number does the label show now?
let coins = 0;
button.onTap = function () {
coins = coins + 1;
label.text = coins;
}; - 35.👆 What kind of event is this: the app starts up? (a) a timer event (b) a text event (c) a tap event (d) a load event
- 36.True or false: the app starts up is a timer event. (a) False (b) True
-
37.👆 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 - 38.True or false: the app starts up is a load event. (a) False (b) True
-
39.👆 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;
}; -
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
- 2
- a tap event
- a text event
- a load event
- 12
- False
- Hi, Meera!
- something that happens
- ON
- 3
- handler
- a timer event
- False
- 10
- ON
- Hi, Riya!
- ON
- Hi, Arjun!
- True
- False
- Welcome, Meera!
- 2
- 6
- the user taps a button
- a timer event
- False
- True
- Hello, Arjun!
- OFF
- 9
- 33
- OFF
- True
- 2
- a load event
- False
- ON
- True
- 3
- 3
Free app development lessons, practice and worksheets at talentjr.in/app-development-for-students