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