Menu

1D Arrays

Card 1 of 18 0 got it 0 still learning
Question
TapClick or press space to see the answer
Answer
All 18 cards in this set
Which term describes a single value stored in an array?
Element
What is meant by 'index'?
The position of an element in an array, counting from 0
Which term describes a data structure that stores several values of one data type under a single identifier?
Array
What is meant by 'append'?
To add a new element to the end of a list
Which term describes the fault that stops a program when it tries to access a position outside the range of an array?
IndexError
In Python, how is a one-dimensional array written?
As a list in square brackets with the elements separated by commas
What does len(scores) give for a list called scores?
The number of elements in the list
What does this program print?
Green
After this program runs, which expression refers to the value 'Rome'?
Index 1, written cities[1]
Why is for i in range(0, len(scores)) used instead of for i in range(0, 5)?
It keeps working when the array holds a different number of elements
What does this program print?
25
Which value should a variable storing the highest value be set to before the loop that finds the highest element starts?
The first element of the array
What does this program print?
3
What does this program print?
['Blue', 'Pink', 'Green', 'Purple', 'Red']
scores = [4, 8, 15, 16, 23]. Which expression gives the last value, 23?
scores[len(scores) - 1]
Why is a set of scores usually stored in one array instead of in separate variables such as score1, score2 and score3?
One loop can process all the values through a single name
What does this program print?
[30, 100, 120, 100, 400]
Where is the first number entered by the user stored?
At index 0, because the loop starts with i set to 0