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