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