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