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