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