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