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