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