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