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