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