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