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