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