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