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