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