Created
March 7, 2016 23:40
-
-
Save fandrefh/9b9c0282968a0d3b4424 to your computer and use it in GitHub Desktop.
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
| fhand = open('mbox-short.txt') | |
| count = 0 | |
| total = 0 # acumuladora/totalizadora | |
| for line in fhand: | |
| line = line.rstrip() | |
| if line.startswith('X-DSPAM-Confidence: '): | |
| count = count + 1 | |
| limit = line.find(':') | |
| line = float(line[limit+1:]) | |
| total = total + line # cálculo, o valor atual mais o valor de cada linha | |
| print (line) | |
| print ('Count:',count) | |
| print ('Sum:',total) | |
| print ('Average:',(total / count)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment