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