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