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