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