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