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