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