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