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