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