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