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