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