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