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