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