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