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