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