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