WorksheetsCP M.8.1-8.5 Quiz Review
Total questions: 15
Worksheet time: 10mins
In Python, an array is called a (a) .
A list stores data using multiple variable names.
True
False
We use lists in programs to ______________ data.
get external
get user
organize
Where does append add the new elements?
To the beginning of an array
To the middle of an array
To the end of an array
In alphabetical/numerical order.
The (a) is the address/location of a piece of data.
A(n) (a) is an individual piece of data in an array.
Consider the following code:
price = [24.99, 20.00, 12.50, 3.99]
This code is an example of a(n) ______________ _____________.
output list
index list
initializer list
parameter list
Why do we use for loops with lists?
Because they take user input.
Because we do not know how many times the loop will repeat.
Because they let us quickly process the contents of a list, which has many values.
Because they allow us to test boolean conditions.
The ___________ method adds a new element onto the end of the list.
add
input
append
len
Consider the following code that works on a list of integers:
for i in range(len(values)):
if (values[i] < 0):
values[i] = values [i] * -1
What does it do?
Changes all negative numbers to positives.
Nothing, values in lists must be positive.
Subtracts one from every value in the list.
Changes all positives numbers to negatives.
_____________ is storing a specific value in the list.
Iterating
Summing
Indexing
Assigning
Arrays perform number calculations.
True
False
Consider the following code:
stuff = ["dog", "cat", "frog", "zebra", "bat", "pig", "mongoose"]
print(stuff[5])
What is output?
pig
dog
['dog', 'cat', 'frog', 'zebra', 'bat', 'pig', 'mongoose']
print(stuff)
Mark the correct position of the element.
The ______() method allows us to add as many elements as we want.
extend
insert
remove
pop
