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