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