Lecture 4 Flashcards
Data structure
Is a specific way of organizing storing and managing data in a computer so that it can be efficiently accessed and modified they help solve complex problems and enable faster algorithms by aligning the data organization with a task at hand
List
A list is a built in data structure in python used to store an ordered collection of items. Lists are mutable meaning their contents can be changed after creation items and lists can be different data types.
Mutable
Elements can be modified, added or removed after list is created
Can if statements be empty
No they must have something to execute it True
pass
Pass command keeps the program moving forward but does not execute any commands
List
Stores an ordered collection (possibly duplicate) items. They are mutable and can be different data types
Mutable
Can be changed after creation
Index
The specific location of an element in a list. Starts at 0, is referenced using []
Append
Add elements to the end of the list using list.append()
Insert element into list at a specific index
List. Insert(idx, )
Remove and return last element in a list
List.pop()
Remove and return element at specified index
List.pop(idx)
Reverse order of list
List.reverse()
Sprt in ascending order
list.sort()
Find length of list
len(list)
Check if element is in a list
Is ‘ ‘ in list
Negative indicies in python lists
Count backwards