Review from CS 161 Flashcards

1
Q

some_primes[0]

A

Returns the element at the 0th index of a list called “some_primes”

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

(len(a_list) - 1)

A

Returns the numeral that corresponds to the highest index position of a list.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Syntax for getter methods

A
def get_length(self):
    """Returns the length of the box."""
    return self._length
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Syntax for a tuple with only one value

A
one = ('just me",) 
# trailing comma needed
How well did you know this?
1
Not at all
2
3
4
5
Perfectly