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