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