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