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