Monday, December 8, 2014

strings

my code for the tweet checker:

def tweet_good(post):
Error = 0
if len(post) > 140:
print "Too long"
if len(post) <140:
print "all good size"

else:
Error = Error + 1
if '!' in post:
Error = Error + 1
if ',' in post:
Error = Error + 1
if '?' in post:
Error = Error + 1
if '"' in post:
Error = Error + 1

else:

if Error >= 5:
print "all good"
if Error < 5:
print "missing things"









tweet check



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 dosent matter because there all the same just characters to python it wouldnt matter.

1.       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.

with only line 3 you would get (one and another), but with line 4 it only would say (d a).

No comments:

Post a Comment