complexitywhere is the length of the array understand how copy worksi the difference between and list(aunderstand what deep copy isand how it differs from shallow copyi how copy copy(adiffers from copy deepcopy(akey methods for list include min( )max( )binary search for sorted lists (bisect bisect( )bisect bisect_left( )and bisect bisect_right( )) reverse((in-place)reversed( (returns an iterator) sort((in-place)sorted( (returns copy)del [ (deletes the -th element)and del [ : (removes the sliceslicing is very succinct way of manipulating arrays it can be viewed as generalization of indexingthe most general form of slice is [ : : ]with all of ijand being optional let [ here are some examples of slicinga[ : is [ ] [ :is [ ] [: is [ ] [:- is [ ] [- :is [ ] [- :- is [ ] [ : : is [ ] [ : :- is [ ]and [::- is [ (reverses listslicing can also be used to rotate lista[ : [:krotates by to the left it can also be used to create copyb [:does (shallowcopy of into python provides feature called list comprehension that is succinct way to create lists list comprehension consists of ( an input sequence( an iterator over the input sequence( logical condition over the iterator (this is optional)and ( an expression that yields the elements of the derived list for example[ ** for in range( )yields [ ]and [ ** for in range( if = yields [ , although list comprehensions can always be rewritten using map()filter()and lambdasthey are clearer to readin large part because they do not need lambdas list comprehension supports multiple levels of looping this can be used to create the product of setse if [ and [' '' ']then [(xyfor in for in bcreates [( ' ')( ' ')( ' ')( ' ')( ' ')( ' ')it can also be used to convert list to liste if [[' '' '' '][' '' '' ']] for row in for in row creates [' '' '' '' '' '' 'two levels of looping also allow for iterating over each entry in liste if [[ ][ ]then [[ ** for in rowfor row in myields [[ ][ ]as general ruleit is best to avoid more than two nested comprehensionsand use conventional nested for loops--the indentation makes it easier to read the program finallysets and dictionaries also support list comprehensionswith the same benefits the dutch national flag problem the quicksort algorithm for sorting arrays proceeds recursively--it selects an element (the "pivot")reorders the array to make all the elements less than or equal to the pivot appear firstfollowed by all the elements greater than the pivot the two subarrays are then sorted recursively implemented naivelyquicksort has large run times and deep function call stacks on arrays with many duplicates because the subarrays may differ greatly in size one solution is to reorder the array so that all elements less than the pivot appear firstfollowed by elements equal to the pivot