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