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