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