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