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