LPCh4 Flashcards

1
Q

what are the builtin sequence types?

A

strings, lists, tuples

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

how to access a component of a sequences?

A

by indexing

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

what is the builtin function to find the length of a sequence?

A

len()

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

in a sequence, what does a negative index do?

A

the index is the offset starting from the end ( the right)

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

when using the square bracket syntax for indexing s[], what can be inside the brackets?

A

any expression - a literal, a variable, an expression

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

what is the syntax to perform slicing on a sequence ?

A

sting[0:4]

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

in the slice s = tag[i:j], is index i and j included in slice?

A

i is, j isn’t

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

s = ‘test’
t = s[0:2]
what is t ?

A

‘tes’

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

what is the syntax for sequence repetition and concatenation

A

‘test’ * 4

‘test’ + ‘more’

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

are python string immutable?

A

yes

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

which builtin types are immutable? which are not

A

immutable - string, tuples, numbers

mutable - dictionary, lists, sets

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