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