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