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