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