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