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