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