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