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