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