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