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