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