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