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