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