Chapter 7 Key Terms Flashcards
Sequence
Is an ordered collection of elements that can be of any data type. Ex: strings, tuples, lists.
List
Is a mutable, ordered collection of elements using square brackets ‘[]’.
Mutable
Elements can be modified after it is created. Change, add, or remove.
Dynamic Data Structure
Structure that can change size by changing, adding, or removing elements.
Repetition Operator *
Is used to repeat a sequence a specified number of times.
Index
A numerical value that represents the position of an element within a sequence.
Starting Index
The index of the first element in a sequence.
Index of Last Element
The last element in a sequence can be found using the formula len(sequence) - 1, where len(sequence) is the length of the sequence.
IndexError Exception
An exception occurs when you try to access an index that is outside the valid range of indices for a sequence.
len
Is used to determine the number of elements in a sequence.
Concatenating Lists
Combining two or more lists into a single list.
Slice
Extracting a portion of a sequence by specifying a range of indices.
in
Is used to check if a particular element exists within a sequence.
append
Is used to add an element to the end of a list.
index
Is used to find the index of the first occurrence of a specified element in a list.