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