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