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