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