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