read whole file in variable
for parts using partition method
for by words by split
if word before in dictionary
add dictionary count
else assign dictionary count for word to 1
output or save count for part
You will also want to know how to do tonyjv's lines 5, 6, 7
The very best way is to use collections.Counter if you have it in your version of Python. Discover whether you do by trying to do this: from collections import Counter If it works, you are golden, and your code looks like this
from collections import Counter
numcounter = Counter()
for line in readlines(theOpenedInputFile):
# numcouner.keys() is the set of distinct numbers seen
Without collections.Counter , there is an obvious way:
#split each line into words and work one word at a time:
if word in countDictionary:
countDictionary[word] += 1
countDictinary[word] = 1
Write a C program that should create a 10 element array of random integers (0 to 9). The program should total all of the numbers in the odd positions of the array and compare them with the total of the numbers in the even positions of the array and indicate ...
I have a 2d matrix with dimension (3, n) called A, I want to calculate the normalization and cross product of two arrays (b,z) (see the code please) for each column (for the first column, then the second one and so on).
the function that I created to find the ...