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