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