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