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