Font size
WorksheetsLists, Loops and Traversals
Total questions: 24
Worksheet time: 3615secs
Which vocabulary word is:
a common method for referencing the elements in a list or string using numbers
list
element
index
Which vocabulary word is:
an ordered collection of elements
list
element
index
Which vocabulary word is:
an individual value in a list that is assigned a unique index
list
element
index
What is the value of i after this code runs?
var myNumbers = [32, 64, 33, 0, 15, 26, 3];
var i = myNumbers[4];
64
15
0
32
//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);
10, 12, 14, 16, 18
10, 12, 14 , 20, 16, 18, 3
3, 12, 14, 20, 16, 18
12, 20, 14, 16, 18, 3
//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)
//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)
//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)
//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);
name
name is
y name
23
n
//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.substring(2, 7);
_name
name_is
y_name
23
n
//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.substring(1, 6);
_name
name_is
y_nam
23
n
//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.substring(3, 10);
_name
name_is
y_name
23
n
1
2
3
6
Error. There is no index 2.
0
1
2
8
Error. Index 3 does not exist.
2
3
4
5
6
4
7
9
10
ab
A Boolean expression is an expression that evaluates to which of the of the following?
Yes/Maybe/No
True/False
Any Integer
Integers between 1 and 10
Any single character
What is a possible output when the following code segment executes? The ending position of the turtle is shown in each diagram. The starting position is shown as a white triangle in cases where the turtle starts and ends in different locations.
A list of numbers has n elements, indexed from 1 to n. The following algorithm is intended to display the number of elements in the list that have a value greater than 100. The algorithm uses the variables count and position. Steps 3 and 4 are missing.
Step 1: Set count to 0 and position to 1.
Step 2: If the value of the element at index position is greater than 100, increase the value of count by 1.
Step 3: (missing step)
Step 4: (missing step)
Step 5: Display the value of count.
Which of the following could be used to replace steps 3 and 4 so that the algorithm works as intended?
Step 3: Increase the value of position by 1.
Step 4: Repeat steps 2 and 3 until the value of count is greater than 100.
Step 3: Increase the value of position by 1.
Step 4: Repeat steps 2 and 3 until the value of position is greater than n.
Step 3: Repeat step 2 until the value of count is greater than 100.
Step 4: Increase the value of position by 1.
Step 3: Repeat step 2 until the value of position is greater than n.
Step 4: Increase the value of count by 1.
Which of the following code segments can be used to move the robot to the gray square?
Select two answers.
