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