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