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