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