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