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