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