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