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