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