wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

LIST

Total questions: 34

Worksheet time: 36mins

Name
Class
Date
1.

Jasmine is writing a shopping app. She has created a variable to keep track of the number of items in the shopping cart. Every time someone clicks the "addItemButton", she would like the variable to increase by 1.


What code should Jasmine insert where it says <missing code> in order for her app to work?

a)

cart total = 1;

b)

cartTotal + 1;

c)

cartTotal = cartTotal +1;

d)

var cartTotal = cartTotal + 1;

e)

var cartTotal + 1;

2.

Consider the following flow chart showing a process for program execution. Given that a = 5, and b = 10, what will be displayed by the program?

a)

a is bigger

b)

b

c)

5

d)

10

e)

Nothing will be displayed

3.

When creating lists, sometimes you will need to create a “scrolling pattern”. 

Which of the following will not scroll beyond the end of a list?

a)

if  (index < myList.length-1) {

Index++

}

b)

if  (index > myList.length-1) {

Index++

}

c)

if  (index < myList.length) {

Index++

}

d)

if  (index > myList.length) {

Index++

}

4.

What does the term 'Element' refer to in a list?

a)

A) A unique identifier for each item

b)

B) A method for looping through a list

c)

C) An individual value in a list that is assigned a unique index

d)

D) The process of naming a collection of data without referencing the details

5.

If I want to place a new element anywhere in a list, I would use which of the following methods?

a)

appendItem

b)

insertItem

c)

addItem

d)

joinItem

6.

myList = [5, 3, 12, 7, 19, 20, 23]. myList.length will return a value of ___

a)

6

b)

7

c)

8

d)

9

7.

The first item in a list has an index of .....

a)

0

b)

1

c)

2

d)

3

8.

Which of these is the correct code for creating a list of names?

a)

nameList = John, Harry, Jesse, John, Harry, Harry

b)

nameList = ("John", "Harry", "Jesse", "John", "Harry", "Harry")

c)

nameList = ["John", "Harry", "Jesse", "John", "Harry", "Harry"]

d)

nameList = [John, Harry, Jesse, John, Harry, Harry]

9.

List items have an index number. In the following list, which item has the index number of 3?

["John", "Harry", "Jesse", "John", "Harry", "Harry"]

a)

"John"

b)

"Harry"

c)

"Jesse"

10.

What is the output of program below?


mariana_islands = ['Saipan', 'Tinian', 'Rota']

mariana_islands[0] = 'Guam'

print(mariana_islands)

a)

['Saipan', 'Tinian', 'Rota']

b)

['Guam', 'Tinian', 'Rota']

c)

['Saipan', 'Tinian', 'Rota', 'Guam']

d)

['Guam', 'Saipan', 'Tinian', 'Rota']

11.

What is the output of program below?


mariana_islands = ['Guam', 'Saipan', 'Tinian', 'Rota']

print(mariana_islands[-1])

a)

Guam

b)

Saipan

c)

Tinian

d)

Rota

12.

What will be displayed in the console when this program runs?

a)

2

b)

3

c)

20

d)

30

13.

What will be displayed when this program finishes running?

a)

3

b)

6

c)

7

d)

5

14.

What is wrong with the following attempt to initialize a list?

data = ["hockey", 4, False]

a)

You should be using parentheses ( ) to surround the items in a list

b)

Nothing, this will work correctly

c)

The "=" sign

d)

You cant have a list with different data types

15.

Which vocabulary word is:

a common method for referencing the elements in a list or string using numbers

a)

list

b)

element

c)

index

16.

var numList = [10,20,30];

console.log ( numList [numList.length-1]);

What will be displayed in the console when this program runs?

a)

2

b)

3

c)

20

d)

30

17.

Which vocabulary word is:

an ordered collection of elements

a)

list

b)

element

c)

index

18.

Which vocabulary word is:

an individual value in a list that is assigned a unique index

a)

list

b)

element

c)

index

19.

Match the index with the value.


var myNumbers = [32, 64, 33, 0, 15, 26, 3]

myNumbers[4]

a)

64

b)

15

c)

0

d)

32

20.

//Consider this code:

var list = [10, 12, 14, 16, 18];

appendItem(list, 3);

insertItem(list, 2, 20);

removeItem(list, 0);


//What is printed to the console?

console.log(list);

a)

10, 12, 14, 16, 18

b)

10, 12, 14 , 20, 16, 18, 3

c)

3, 12, 14, 20, 16, 18

d)

12, 20, 14, 16, 18, 3

21.

//Consider this code:

var list = [10, 12, 14, 16, 18];

appendItem(list, 3);

insertItem(list, 2, 20);

removeItem(list, 0);


//What is printed to the console?

console.log(list[0]);

(a)  

22.

//Consider this code:

var list = [10, 12, 14, 16, 18];

appendItem(list, 3);

insertItem(list, 2, 20);

removeItem(list, 0);


//What is printed to the console?

console.log(list.length);

(a)  

23.

//Consider this code:

var list = [10, 12, 14, 16, 18];

appendItem(list, 3);

insertItem(list, 2, 20);

removeItem(list, 0);


//What is printed to the console?

console.log(list[list.length-1]);

(a)  

24.

//Consider this code.


var beginning = "My name is ";

var end = "Mrs. Anderson";

var sentence = beginning + end;


//What is printed to the console?

console.log(sentence.length);

a)

name

b)

name is

c)

y name

d)

23

e)

n

25.
a)

4

b)

7

c)

9

d)

10

e)

ab

26.

A sequence of several variables, grouped together under a single name.

a)

sequence

b)

list

c)

length

d)

element

27.

What is the name of this list?

a)

Foodlunch

b)

lunchfood

c)

LunchFood

d)

lunchFood

28.

Refers to the number of elements that a list can hold.

a)

[list].length

b)

[list].length-1

29.

What is this a picture and example of?

a)


[list].length

b)


[list].length-1

30.

What is this a picture and example of?

a)

Random Access List Pattern

b)

Scrolling List Pattern

31.

var list = [10, 12, 14, 16, 18];

removeItem(list, 0);

console.log(list[0]);

a)

12

b)

14

c)

16

d)

0

32.

//Consider this code:

var list = [10, 12, 14, 16, 18];

//What is printed to the console?

console.log(list[list.length-1]);

a)

10

b)

16

c)

18

d)

14

33.

What does this code do? names[0]="Chenda";

a)

replaces an item in the list at index 0

b)

adds an item or items to the END of a list

c)

adds an item at a SPECIFIC INDEX in the list

d)

deletes an item from the list.

34.

wordList is a list of words that currently contains the values ["tree", "rock", "air"] Which of the following lines will result in the list containing the values ["air", "rock", "air"] ?

a)

wordList[0] = wordList[2]

b)

wordList[2] = wordList[0]

c)

insertItem(wordList, 0, "air")

d)

removeItem(wordList,0)