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