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