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