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