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