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