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