This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mails = dict() | |
for line in open( raw_input("Enter File Name:")): | |
words = line.strip().split() | |
if len(words) == 0 and len(words)<2: | |
continue | |
if words[0] == 'From': | |
hours = words[5].split(':') | |
if hours[0] not in mails: | |
mails[hours[0]] = 1 | |
else: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
count = dict() | |
for line in open(raw_input("Enter File Name:")): | |
words = line.strip().split() | |
if len(words) == 0 or len(words) <3: | |
continue | |
if words[0] == 'From': | |
if words[1] not in count: | |
count[words[1]] = 1 | |
else: | |
count[words[1]] += 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
count = 0 | |
for mail in open(raw_input("Enter file name:")): | |
mail = mail.rstrip() | |
if mail.startswith("From "): | |
count +=1 | |
words = mail.split() | |
print words[1] | |
print "There were",count,"lines in the file with From as the first word" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
finlist = list() | |
for line in open(raw_input("Enter the file Name:")): | |
words = line.rstrip().split() | |
for arr in words: | |
if arr in finlist: | |
continue | |
else: | |
finlist.append(arr) | |
finlist.sort() | |
print finlist |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sum = 0.0 | |
count = 0 | |
fname = open(raw_input("Enter file name: ")) | |
for line in fname: | |
if not line.startswith("X-DSPAM-Confidence:") : continue | |
sum = sum + float(line[line.find(" ")+1:]) | |
count = count + 1 | |
print "Average spam confidence:",sum/float(count) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for data in open(raw_input("Enter file name: ")): | |
print data.rstrip().upper() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
text = "X-DSPAM-Confidence:0.8475" | |
epos = text.find(':') | |
print float(text[epos+1:]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
largest = None | |
smallest = None | |
while True: | |
num = raw_input("Enter a number:") | |
try: | |
if num == 'done': | |
print "Maximum is",largest | |
print "Minimum is",smallest | |
break | |
num = int(num) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def computepay(hours,rate): | |
if hours>40.0: | |
p = rate * 40.0 | |
p = p+(1.5*rate*(hours-40)) | |
else: | |
p = rate*hours | |
return p | |
hours = float(raw_input("Enter worked hours: ")) | |
rate = float(raw_input("Enter Pay rate per hour: ")) | |
print computepay(hours,rate) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
score = float(raw_input("Enter score between 0.0 and 1.0: ")) | |
if score>1.0 or score<0.0 : | |
print "error" | |
elif score>=0.9 : | |
print 'A' | |
elif score>=0.8 : | |
print 'B' | |
elif score>=0.7 : | |
print 'C' | |
elif score>=0.6 : |
NewerOlder