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