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