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