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