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