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