Tweet
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. Yes becuase unicode uses four bytes per character, and ASCII uses one byte per character. unicode offers a wider range of characters.
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])
a is stored, and b is stored. c is stored as 'one' from a, a new part; ' and ' and b. then the print command calls c, but only characters 6 through 10; "d an"
No comments:
Post a Comment