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