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