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