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