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