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