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