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