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