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