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