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