Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- """
- Created on Wed Mar 27 18:10:31 2013
- Exercise 7.1 shout.py
- @author: casa
- """
- #f = open('mbox-short.txt', 'r')
- fname = raw_input("Enter a file name: ")
- try :
- f = open(fname)
- except :
- print "The file %s doesn't exist or could not be opened." % fname
- smalltext = f.readlines()
- for line in smalltext :
- line = line.rstrip()
- print line.upper()
- f.close()
- exit()
- """
- Created on Fri Mar 29 18:36:13 2013
- Exercise 7.2 SPAM confidence
- @author: casa
- """
- #f = open('mbox-short.txt', 'r')
- fname = raw_input("Enter a file name: ")
- try :
- f = open(fname)
- except :
- print "The file %s doesn't exist or could not be opened." % fname
- l = list()
- for line in f :
- if line.startswith('X-DSPAM-Confidence') :
- value = line[20:26]
- l.append(float(value))
- print ("The average SPAM confidence is: "), sum(l)/len(l)
- exit()
- """
- Created on Fri Mar 29 18:36:13 2013
- Exercise 7.3
- @author: casa
- """
- #f = open('mbox-short.txt', 'r')
- fname = raw_input("Enter a file name: ")
- if fname == "na na boo boo" :
- print "Do you think it's Eastern this weekend?"
- exit()
- try :
- f = open(fname)
- except :
- print "The file %s doesn't exist or could not be opened." % fname
- count = 0
- for line in f :
- if line.startswith("Subject") :
- count = count + 1
- print ("There were %d subject lines in %s: ") % (count, fname)
- exit()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement