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