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