Advertisement
biswasrohit20

n

Apr 25th, 2021
241
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.42 KB | None | 0 0
  1. myfile = open('numbers.txt')
  2. next_line = myfile.readline()
  3. listA = []
  4. listB = []
  5. while next_line != "":
  6. listA.append(float(next_line.split(",")[0]))
  7. listB.append(float(next_line.split(",")[1][:-1]))
  8. next_line = myfile.readline()
  9.  
  10. print("The average of the first column is: " + "{:.4f}".format(sum(listA)/len(listA)))
  11. print("The average of the second column is: " + "{:.4f}".format(sum(listB)/len(listB)))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement