← Data: variables, lists and saving lesson New set →

App Dev Worksheet: Variables, Lists and Saving

App development lesson 15: Data: variables, lists and saving · Set 484 · 40 questions
TalentJR

Developer's tip (Box, list, place): A variable holds one value; a list holds many in order. Positions start at 0. push adds to the end; pop takes off the last item; length is how many items. On the phone: works offline, private. In the cloud: shared, any device, needs the internet.

NameDateTime takenScore ___ / 40
  1. 1.💾 What number does this code show?
    let friends = ["Zoya", "Aman", "Arjun", "Riya"];
    friends.push("Meera");
    show(friends.length);
  2. 2.💾 What number does this code show?
    let lives = 6;
    lives = lives - 4;
    lives = lives + 4;
    show(lives);
  3. 3.💾 What is a variable? (a) a named box for a value (b) a type of screen (c) a phone setting (d) a picture
  4. 4.💾 What does this code show? (Positions start at 0.)
    let songs = ["Rain", "Stars", "Ocean", "Monsoon", "Kites"];
    show(songs[1]);
    (a) Rain (b) Ocean (c) Stars (d) Monsoon
  5. 5.💾 What number does this code show?
    let songs = ["Monsoon", "Kites", "Rain"];
    songs.push("Sunrise");
    songs.push("Stars");
    show(songs.length);
  6. 6.💾 What does this code show? (Positions start at 0.)
    let friends = ["Zoya", "Kabir", "Arjun", "Riya", "Aman"];
    show(friends[4]);
    (a) Kabir (b) Aman (c) Arjun (d) Zoya
  7. 7.💾 In most code, the first item of a list is at position ___. (a) 10 (b) 1 (c) 0 (d) 2
  8. 8.💾 What number does this code show?
    let coins = 4;
    coins = coins - 1;
    coins = coins + 5;
    show(coins);
  9. 9.True or false: your last game level fits saving on the phone. (a) False (b) True
  10. 10.💾 Which works with no internet at all? (a) a cloud backup (b) data saved on the phone (c) a cloud leaderboard (d) a shared chat
  11. 11.Which of these fits saving on the phone? (a) the sound on/off setting (b) a class leaderboard (c) photos on two devices (d) chat messages to friends
  12. 12.💾 Where should the app save a shared to-do list: on the phone or in the cloud? (a) on the phone (b) in the cloud
  13. 13.💾 What number does this code show?
    let songs = ["Sunrise", "Ocean"];
    songs.push("Stars");
    songs.push("Rain");
    show(songs.length);
  14. 14.True or false: the sound on/off setting fits saving in the cloud. (a) False (b) True
  15. 15.💾 Data saved only on the phone is lost when ___. (a) you send a message (b) the app is closed (c) the phone is lost (d) the screen turns off
  16. 16.Which of these fits saving in the cloud? (a) a draft you are typing (b) the sound on/off setting (c) your last game level (d) chat messages to friends
  17. 17.Which of these fits saving in the cloud? (a) the sound on/off setting (b) photos on two devices (c) your last game level (d) notes to read offline
  18. 18.💾 What does this code show? (Positions start at 0.)
    let friends = ["Meera", "Arjun", "Zoya", "Aman"];
    show(friends[3]);
    (a) Aman (b) Meera (c) Zoya (d) Arjun
  19. 19.💾 What number does this code show?
    let songs = ["Kites", "Stars", "Monsoon", "Ocean"];
    songs.push("Rain");
    songs.push("Sunrise");
    show(songs.length);
  20. 20.💾 pop() takes off the last item. What does this code show?
    let friends = ["Riya", "Aman", "Zoya", "Meera", "Kabir"];
    friends.pop();
    show(friends[friends.length - 1]);
    (a) Aman (b) Meera (c) Zoya (d) Riya
  21. 21.💾 What number does this code show?
    let notes = ["Sports", "Maths", "Art"];
    notes.push("Hindi");
    notes.push("Science");
    show(notes.length);
  22. 22.💾 What number does this code show?
    let songs = ["Monsoon", "Sunrise"];
    songs.push("Stars");
    songs.push("Ocean");
    show(songs.length);
  23. 23.💾 pop() takes off the last item. What does this code show?
    let notes = ["Science", "Maths", "Art"];
    notes.pop();
    show(notes[notes.length - 1]);
    (a) Maths (b) Science (c) Art
  24. 24.💾 What does this code show? (Positions start at 0.)
    let songs = ["Kites", "Rain", "Stars"];
    show(songs[2]);
    (a) Rain (b) Stars (c) Kites
  25. 25.True or false: a draft you are typing fits saving in the cloud. (a) False (b) True
  26. 26.True or false: photos on two devices fits saving in the cloud. (a) False (b) True
  27. 27.💾 pop() takes off the last item. What does this code show?
    let songs = ["Sunrise", "Kites", "Ocean", "Stars"];
    songs.pop();
    show(songs[songs.length - 1]);
    (a) Sunrise (b) Stars (c) Kites (d) Ocean
  28. 28.💾 Where should the app save a draft you are typing: on the phone or in the cloud? (a) in the cloud (b) on the phone
  29. 29.Which of these fits saving on the phone? (a) chat messages to friends (b) photos on two devices (c) your last game level (d) a class leaderboard
  30. 30.💾 What number does this code show?
    let notes = ["Science", "Art", "Music"];
    notes.push("Maths");
    notes.push("Sports");
    show(notes.length);
  31. 31.💾 What number does this code show?
    let points = 5;
    points = points - 5;
    points = points + 5;
    show(points);
  32. 32.💾 What number does this code show?
    let score = 3;
    score = score - 1;
    score = score + 5;
    show(score);
  33. 33.True or false: a shared to-do list fits saving on the phone. (a) False (b) True
  34. 34.💾 What number does this code show?
    let score = 7;
    score = score - 4;
    score = score + 3;
    show(score);
  35. 35.True or false: chat messages to friends fits saving on the phone. (a) True (b) False
  36. 36.💾 Where should the app save the sound on/off setting: on the phone or in the cloud? (a) on the phone (b) in the cloud
  37. 37.💾 Where should the app save a class leaderboard: on the phone or in the cloud? (a) on the phone (b) in the cloud
  38. 38.💾 pop() takes off the last item. What does this code show?
    let notes = ["Art", "Maths", "Hindi", "Science"];
    notes.pop();
    show(notes[notes.length - 1]);
    (a) Hindi (b) Maths (c) Art (d) Science
  39. 39.💾 pop() takes off the last item. What does this code show?
    let songs = ["Ocean", "Monsoon", "Kites", "Sunrise"];
    songs.pop();
    show(songs[songs.length - 1]);
    (a) Ocean (b) Sunrise (c) Kites (d) Monsoon
  40. 40.💾 What number does this code show?
    let songs = ["Monsoon", "Stars", "Ocean"];
    songs.push("Sunrise");
    show(songs.length);

Answer key

  1. 5
  2. 6
  3. a named box for a value
  4. Stars
  5. 5
  6. Aman
  7. 0
  8. 8
  9. True
  10. data saved on the phone
  11. the sound on/off setting
  12. in the cloud
  13. 4
  14. False
  15. the phone is lost
  16. chat messages to friends
  17. photos on two devices
  18. Aman
  19. 6
  20. Meera
  21. 5
  22. 4
  23. Maths
  24. Stars
  25. False
  26. True
  27. Ocean
  28. on the phone
  29. your last game level
  30. 5
  31. 5
  32. 7
  33. False
  34. 6
  35. False
  36. on the phone
  37. in the cloud
  38. Hindi
  39. Kites
  40. 4

Free app development lessons, practice and worksheets at talentjr.in/app-development-for-students