Unit 13 Flashcards
13.2 - List Methods
What is a list method?
functions specifically used for lists
append, remove, sort, etc.
13.3 - Iterating Over a List
What does all(xlist)
do?
true if every element != 0 or the list is empty
13.3 - Iterating Over a List
What does any(xlist)
do?
true if any element in the list is true
13.3 - Iterating Over a List
What does max(xlist)
do?
gets highest element in list
13.3 - Iterating Over a List
What does min(xlist)
do?
gets the minimum element in the list
13.3 - Iterating Over a List
What does sum(xlist)
do?
gets the sum of all elements in the list
13.5 - List Nesting
How do you get a singular value in a nested list?
xlist[0][0]
13.8 - Sorting Lists
What is the difference between .sort()
, .sorted
, and .reverse()
?
.sort
- sorts list in place.sorted
- new list as seperate entity.reverse
- reverses list
13.10 - List Comprehensions
What is a list comprehension?
uses a for loop to assign a variablexlist = expression for name in iterable