Review from CS 161 Flashcards
1
Q
some_primes[0]
A
Returns the element at the 0th index of a list called “some_primes”
2
Q
some_primes[0:10:2]
A
Returns every 2nd element of a list named “some_primes”, starting with the 0th and ending with the 10th element.
3
Q
some_stuff[3][0]
A
Indexes to the 3rd item of a list called “some_stuff,” and then indexes into the 3rd item to return the 0th element of the sublist.
4
Q
(len(a_list) - 1)
A
Returns the numeral that corresponds to the highest index position of a list.
5
Q
Syntax for getter methods
A
def get_length(self): """Returns the length of the box.""" return self._length
6
Q
Syntax for a tuple with only one value
A
one = ('just me",) # trailing comma needed