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