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