Friday, December 5, 2014

1.3.5

Goals
    • No More then 140 Characters
    • That the following Characters were used ( ,  "  !  ?)
Code

def eligible(essay):
    a=0
    if len(essay)<=140:
        a+=1
    else:
        print ("Your essay is to long! It must be shorter than 140 characters!")
    if '?' in essay:
        a+=1
    else:
        print ("Your essay needs a question(?)!")
    if '"' in essay:
        a+=1
    else:
        print ("Your essay needs a quote("")!")
    if ', and' or ', or' or ', but' in essay:
        a+=1
    else:
        print ("Your essay needs a compound sentence(, and/, or/, but)!")
    if '!' in essay:
        a+=1
    else:
        print ("Your essay needs an exclaimation(!)!")
    if a==5:
        print ("Thank You! Your essay has been submited.")
    else:
        print ("Please fix your essay and resubmit it.")


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?
41 characters are in this sentence. Yes it matters, because it will take up four times more space

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 and b are saved in the code and c is defined as a[:3] + 'and' +b. When these variables are called, the code will take what is defined and use it for the variables.

No comments:

Post a Comment