LPCh4 Flashcards
what are the builtin sequence types?
strings, lists, tuples
how to access a component of a sequences?
by indexing
what is the builtin function to find the length of a sequence?
len()
in a sequence, what does a negative index do?
the index is the offset starting from the end ( the right)
when using the square bracket syntax for indexing s[], what can be inside the brackets?
any expression - a literal, a variable, an expression
what is the syntax to perform slicing on a sequence ?
sting[0:4]
in the slice s = tag[i:j], is index i and j included in slice?
i is, j isn’t
s = ‘test’
t = s[0:2]
what is t ?
‘tes’
what is the syntax for sequence repetition and concatenation
‘test’ * 4
‘test’ + ‘more’
are python string immutable?
yes
which builtin types are immutable? which are not
immutable - string, tuples, numbers
mutable - dictionary, lists, sets