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