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