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