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