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