This file contains hidden or 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
| name = raw_input("Enter file:") | |
| if len(name) < 1 : name = "mbox-short.txt" | |
| handle = open(name) | |
| d=dict() | |
| for line in handle: | |
| if not line.startswith("From "): | |
| continue | |
| else: | |
| line=line.split() | |
| line=line[5] |
This file contains hidden or 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: ") | |
| if num == "done" : break | |
| try: | |
| num = int(num) | |
| except: | |
| print "Invalid input" | |
| continue |
This file contains hidden or 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
| hrs = raw_input("Enter Hours:") | |
| h = float(hrs) | |
| rate = raw_input("Enter Rates:") | |
| r = float(rate) | |
| def computepay(h,r): | |
| if h > 40: | |
| payoff = 40*r +(h-40)*1.5*r | |
| else: | |
| payoff = h*r |
This file contains hidden or 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
| name = raw_input("Enter file:") | |
| if len(name) < 1 : name = "mbox-short.txt" | |
| handle = open(name) | |
| d = dict() | |
| for line in handle: | |
| if not line.startswith("From "): | |
| continue | |
| else: | |
| list=line.split() | |
| list=list[1] |
This file contains hidden or 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
| # Use the file name mbox-short.txt as the file name | |
| fname = raw_input("Enter file name: ") | |
| fh = open(fname) | |
| count = 0 | |
| total = 0 | |
| for line in fh: | |
| if not line.startswith("X-DSPAM-Confidence:") : continue | |
| t=line.find("0") | |
| number= float(line[t:]) | |
| count = count + 1 |
This file contains hidden or 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"; | |
| t = text.find("0") | |
| h = text[t:t+6] | |
| h = float(h) | |
| print h |
This file contains hidden or 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
| # Use words.txt as the file name | |
| fname = raw_input("Enter file name: ") | |
| fh = open(fname) | |
| for line in fh: | |
| line_upper=line.upper() | |
| line_strip=line_upper.rstrip() | |
| print line_strip |
This file contains hidden or 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
| fname = raw_input("Enter file name: ") | |
| fh = open(fname) | |
| count=0 | |
| for line in fh: | |
| if not line.startswith("From "): | |
| continue | |
| else: | |
| list=line.split() | |
| print list[1] | |
| count=count+1 |
This file contains hidden or 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
| fname = raw_input("Enter file name: ") | |
| fh = open(fname) | |
| lst = list() | |
| for line in fh: | |
| line=line.rstrip() | |
| line= line.split() | |
| for c in line: | |
| if c in lst: | |
| continue | |
| else: |