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