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