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