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