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