CSCI 1105 Chapter 6(Latest Exam 2024)
What is a list in Python? - correct answers✅a container
that stores a collection of elements that are arranged in a
linear or sequential order
Given the following list, what value is at index 5?
values
= [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] - correct answers✅6
Consider the following line of code: somelist = ["a", "b",
"c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p",
"q", "r", "s", "t", "u", "v", "w", "x", "y", "z"] Which one of
the following options is a valid line of code for displaying
the element at the twenty-second position in the list? -
correct answers✅print(somelist[21])
Given the list below, what are the upper and lower
bounds? somelist = ["a", "b", "c", "d", "e", "f", "g", "h", "i",
"j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v",
"w", "x", "y", "z"] - correct answers✅0, 25
What is the valid range of index values for a list? -
correct answers✅at least zero and less than the
number of elements in the list
What is printed after executing the following code
snippet? somelist = ["a", "b", "c", "d", "e", "f", "g", "h", "i",
"j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v",
,CSCI 1105 Chapter 6(Latest Exam 2024)
"w", "x", "y", "z"] for i in range(len(somelist)) :
print(somelist[i], end = "") - correct
answers✅abcdefghijklmnopqrstuvwxyz
What is printed after executing the following code
snippet? somelist = ["a", "b", "c", "d", "e", "f", "g", "h", "i",
"j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v",
"w", "x", "y", "z"] for i in range(0, len(somelist), 2) :
print(somelist[i], end = "") - correct
answers✅acegikmoqsuwy
Which statement correctly creates a list that contains four
elements? - correct answers✅values = [1, 2, 3, 4]
What is the difference between a list and a string? -
correct answers✅lists can hold values of any type,
whereas strings are only sequences of characters
Which statement gets the length of the list values? -
correct answers✅numValues = len(values)
Given a list values that contains the first ten prime
numbers, which statement prints the index and value of
each element in the list? - correct answers✅for i in
range(10): print(i, values[i])
, CSCI 1105 Chapter 6(Latest Exam 2024)
Given a list values that contains the first ten prime
numbers, which statement does NOT print each element
in the list? - correct answers✅for i in range(1,
len(values)) : print(values[i])
For the list: prices = [10.00, 15.50, 13.25, 20.15], what
value is contained in prices? - correct answers✅the
location of the list
Given the following code snippet, which statement
correctly creates an alias for the list prices? prices =
[10.00, 15.50, 13.25, 20.15] - correct answers✅values
= prices
Which of the following statements stores the numbers 1
through 5 into a list namedvalues? - correct
answers✅values = [1, 2, 3, 4, 5]
Consider the following code segment: values = [4, 12, 0,
1, 5] print(values[1]) What is displayed when it runs? -
correct answers✅12
Which statement displays the last element in the list? -
correct answers✅print(values[4])
Consider the following code segment: values = [1, 2, 3, 4,
5] moreValues = values moreValues[3] = 6 print(values)