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