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