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