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