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