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