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