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