Answer the following questions briefly!
Q1: In what sense is a "string" of characters a sequence? What is a sequence after all? A concrete data type, or something else?
< your answer >
Q2: What is a direct consequence of the str
type's property of being an ordered sequence? What operations could we not do with it if it were unordered?
< your answer >
Q3: What does it mean for an object to be immutable? Discuss how we can verify the str
type's immutability by comparing the two variables example
and full_slice
below. Are they pointing to the same object in memory?
example = "text"
full_slice = example[:]
Hint: Find out what [:]
does first!
< your answer >
Q4: Describe in your own words what we mean by string interpolation!
< your answer >
Motivate your answer with one short sentence!
Q5: Triple-double quotes """
and triple-single quotes '''
create a new object of type text
that models so-called multi-line strings.
< your answer >
Q6: A substring is a string that subsumes another string.
< your answer >
Q7: Indexing into a str
object with a negative index fails silently: It does neither raise an error nor do anything useful.
< your answer >
Q8: We cannot assign a different character to an index or slice of a str
object because it is immutable.
< your answer >