Advertisement
Guest User

Untitled

a guest
Oct 15th, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. a = open("liukulukuja.txt", "r")
  2. b = open("valmiitalukuja.txt", "w")
  3. m=0
  4. while True:
  5. f = a.readline()
  6. w = f.strip("\n")
  7. q = w.strip()
  8. if len(q):
  9. x=float(q)
  10. c=round(x,2)
  11. b.write(str(c)+"\n")
  12. x = q.replace(".","")
  13. m+=len(x)
  14. if len(q)==0:
  15. break
  16.  
  17.  
  18.  
  19. b.close()
  20.  
  21. d = open("valmiitalukuja.txt", "r")
  22.  
  23. total=0
  24. while True:
  25. g = d.readline()
  26. h = g.strip("\n")
  27. j = h.strip()
  28. if len(j):
  29. total += float(j)
  30. if len(j)==0:
  31. break
  32.  
  33.  
  34. print(total)
  35. print(m)
  36. a.close()
  37. d.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement