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