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