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