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