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.
insert
Is used to add an element at a specific index within a list.
sort
Is used to arrange the elements of a list in ascending order.
remove
Is used to remove the first occurrence of a specified element from a list.
reverse
Is used to reverse the order of elements in a list.
del
Is used to remove an element or slice from a list by specifying the index or range of indices.
min
Is used to find the smallest element in a list.
max
Is used to find the largest element in a list.
Copying a List
Creating a new list with the same elements as the original list.
Adding Values in a List
Involves using methods like append or insert.