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