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