Activity 1.3.5:Strings
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?
There are 41 characters in that sentence. it doesn't matters if Python stores a string as 1 byte or 4 bytes as.
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.
one and another
In []: a = 'one string'
In []: b = 'another'
In []: c = a[:3] + ' and ' + b
In []: print(c[6:10])
When this code is executed it will print 'd an' because of slicing. Slicing is when it takes a specific area of a desired string, and you can combine different strings to get a result.
No comments:
Post a Comment