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?
42 Charactors. To me the amount of bytes per charactor is really unimportant. The only important thing is that the script functions properly.
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])
I believe that the aboce code will pull out the first three characters of string 'a', add an ' and ' as well as placing string 'b' in the phrase. The new string: "C" will now read 'one and another'. The print will then type out charactor 6-10 from C saying: ''d an"
I believe that the aboce code will pull out the first three characters of string 'a', add an ' and ' as well as placing string 'b' in the phrase. The new string: "C" will now read 'one and another'. The print will then type out charactor 6-10 from C saying: ''d an"
No comments:
Post a Comment