1. How many characters are in this sentence? Does it matter whether Python is storing the string as one byte per character or four bytes per character?
41 characters are in the sentence. It should not matter as long as it is consistently stored.
2. This question asks you about something you have not learned. In fact, the question is asking about details that go beyond what you will learn in this course. However, wondering what is going on at a lower level of abstraction – and talking about it – can be a useful strategy when learning about computing.
Describe what you think occurs in memory when the following code is executed.
In []: a = 'one string'
In []: b = 'another'
In []: c = a[:3] + ' and ' + b
In []: print(c[6:10])
It sets 2 variables and the 3rd line takes certain characters out of the strings and sets it to 'C', which equals ona and another. It then says to print the 6th through the 10th character making it print: 'd an'.
No comments:
Post a Comment