This code snip checks the eligibility of a "tweet" by verifying that it contains a question, a compound sentence, an exclamation, and that the number of symbols does not exceed a value of max_characters (default, 140).
Conclusion
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 this sentence. It does not matter that python is storing the string as one byte per character or four bytes per character.
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 think that Python would take ratios of each string, and only display a portion of the strings. So the variable c would contain a[:3], a third of 'one string,' or 3 characters, 'one.' It would then add the ' and ' and b, then display another ratio of c itself, [6:10].
No comments:
Post a Comment