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