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