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