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