lists loops and traversals

0.0(0)
studied byStudied by 0 people
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/103

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

104 Terms

1
New cards

A school is developing a program to keep track of information about students and their class schedules. In which of the following instances would a data abstraction be most helpful?

2
New cards
3
New cards

A. The program includes individual variables to store the names of each student rather than a single list of students.

4
New cards

B. A program includes multiple comments that could be combined into a single comment

5
New cards

C. A program includes repeated programming statements that could be moved inside a loop

6
New cards

D. A program includes repeated code that could be moved inside a function.

A. The program includes individual variables to store the names of each student rather than a single list of students.

7
New cards

Which of the following will result in ONLY all the items in list being printed to the console if placed where the program reads and the program is run?

8
New cards
9
New cards

A. i < list[list.length]

10
New cards

B. i < list.length

11
New cards

C. i < list[0]

12
New cards

D. i < list[1]

A. The program includes individual variables to store the names of each student rather than a single list of students.

13
New cards

wordList is a list of words that currently contains the values ["tree", "rock", "air"]

14
New cards

Which of the following lines will result in the list containing the values ["air", "rock", "air"]

15
New cards
16
New cards

A. wordList[0] = wordList[2]

17
New cards

B. wordList[2] = wordList[0]

18
New cards

C. insertItem(wordList, 0, "air")

19
New cards

D. removeItem(wordList,0)

A. wordList[0] = wordList[2]

20
New cards

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

21
New cards

var numList = [10,20,30];

22
New cards

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

23
New cards
24
New cards

A. 2

25
New cards

B. 3

26
New cards

C. 20

27
New cards

D. 30

D. 30

28
New cards

What will be displayed when this program finishes running?

29
New cards

var numbersList = [20, 10, 5]

30
New cards

appendItem(numbersList, 50)

31
New cards

appendItem(numbersList,100)

32
New cards

removeItem(numbersList,1)

33
New cards

insertItem(numbersList, 0, 30)

34
New cards
35
New cards

console.log(numbersList.length)

36
New cards
37
New cards

A. 3

38
New cards

B. 6

39
New cards

C. 7

40
New cards

D. 5

D. 5

41
New cards

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

42
New cards
43
New cards

A. 0246

44
New cards

B. 024

45
New cards

C. 246

46
New cards

D. The program will result in an infinite loop

D.

47
New cards

The program will result in an infinite loop

48
New cards

What will the following program display in the console?

49
New cards
50
New cards

A. 0123

51
New cards

B. 01234

52
New cards

C. 123

53
New cards

D. 1234

A.

54
New cards

0

55
New cards

1

56
New cards

2

57
New cards

3

58
New cards

What will the following program display in the console?

59
New cards
60
New cards

A. 0

61
New cards

B. 5

62
New cards

C. 10

63
New cards

D. 15

C. 10

64
New cards

The following question uses a robot in a grid of squares. The robot is represented by a triangle, which is initially facing up.

65
New cards

Which of the following programs will move the robot to the gray square following the path shown on the grid?

Repeat 2 times

66
New cards

Repeat 3 times

67
New cards

Move_Foreward

68
New cards

Turn left

69
New cards

ageList and gradeList contain information about students in a classroom. A programmer has already written the following code with that information.

70
New cards
71
New cards

Which of the following programs will result in filteredNames only containing the names of students who are 17 or older?

D

72
New cards

If the program above is run, what will be displayed in the console?

73
New cards
74
New cards

A. [apple, dream]

75
New cards

B. [bug, car, ear]

76
New cards

C. [bug, car, ear, food]

77
New cards

D. [apple, dream, food]

B. [bug, car, ear]

78
New cards

A program is designed to determine the minimum value in a list of positive numbers called numList. The following program was written

79
New cards

Which of the following can be used to replace so that the program works as intended for every possible list of positive numbers?

80
New cards
81
New cards

A. 0

82
New cards

B. 1000000

83
New cards

C. numList.length

84
New cards

D. numList[0]

D. numList[0]

85
New cards

A 2-sided coin has an equal likelihood of landing on each side. One side is called "heads" and the other is called "tails". The program below simulates randomly flipping that coin many times.

86
New cards

Which of the following is NOT a possible combination of values of the variables in this program when it finishes running?

87
New cards
88
New cards

A. tails has a value of 0 and heads has a value of 100

89
New cards

B. tails has a value of 100 and heads has a value of 0

90
New cards

C. tails has a value of 20 and heads has a value of 20

91
New cards

D. tails has a value of 50 and heads has a value of 50

C. tails has a value of 20 and heads has a value of 20

92
New cards

A restaurant knows from historical data that 60 out of 100 of its customers purchase a full meal while 40 out of 100 only order a side dish. The program below is intended to simulate the orders of 1000 customers.

93
New cards

Which of the following can be used to replace so that the simulation works as intended?

94
New cards
95
New cards

A. random(1,100) = 40

96
New cards

B. random(1,100) = 60

97
New cards

C. random(1,100) <= 40

98
New cards

D. random(1,100) <= 60

D. random(1,100) <= 60

99
New cards

A job placement agency helps match job seekers with potential employers. The agency would like to design a simulation in order to help predict the likely job placement outcomes for job seekers based on historical trends and patterns. Which of the following is most likely to be a benefit of the simulation?

100
New cards