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