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