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