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