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