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