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