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