- Line 1 is defining the function "check_twitter"
- Line 2 sets "message" equal to the user's input after they are prompted with "Enter Tweet here:"
- Line 3-4 say that if the message is longer than 140 characters, the console will return with the message "Sorry, your tweet is longer than 140 characters; please try again."
- Line 5-6 say that if either a comma, an exclamation point, or a question mark are missing from the user's tweet, the console will return with the message "Sorry, you seem to be missing either: , ! or ? Please try again." This will only occur once the tweet is less than 140 characters.
- Lines 7-8 say that if the tweet meets all of the guidelines, the console will return with the message "Great, thanks for tweeting!"
Conclusion Questions:
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?
It depends on which language the code is to be written in; some languages such as English use one byte per character, while Unicode uses 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])
This code creates a string "c" that adds the first 3 characters of string "a" to "and", and to the entire string "b". Thus string "c" would be "one and another".
The code would print "d an".
Looks good. Comments can go right in the code using the '#' symbol at the end of the line
ReplyDelete