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