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