Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #45761

RE: file I/O and arithmetic calculation

From Carlos Nepomuceno <carlosnepomuceno@outlook.com>
Subject RE: file I/O and arithmetic calculation
Date 2013-05-23 03:02 +0300
References <knjlr4$v6m$6@dont-email.me>
Newsgroups comp.lang.python
Message-ID <mailman.1982.1369267337.3114.python-list@python.org> (permalink)

Show all headers | View raw


----------------------------------------
> From: denismfmcmahon@gmail.com
[...]
>
> import re
> def v(s):
> l=len(s)
> t=0.
> for i in range(l):
> t=t+(abs(ord(s[i]))*1.)
> return t/(l*1.)
> for n in range(5):
> m="c:/test/"+str(n+1)+".txt"
> f=open(m,"r")
> d=[]
> t=0.
> for l in range(10):
> d=d+[re.findall(r"[0-9.eE+-]+",f.readline())]
> t=t+v(d[l][0])
> f.close()
> c=t/10.
> if c==50.:
> t=0.
> for u in range(10):
> t=t+v(d[0][u])
> r=t/10.
> print "%s C1: %f R1: %f"%(m,c,r)
>
> --
> Denis McMahon, denismfmcmahon@gmail.com
> --
> http://mail.python.org/mailman/listinfo/python-list

Can you send it again without tabs? 		 	   		  

Back to comp.lang.python | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

file I/O and arithmetic calculation Keira Wilson <wilkeira@gmail.com> - 2013-05-23 01:13 +0900
  Re: file I/O and arithmetic calculation Denis McMahon <denismfmcmahon@gmail.com> - 2013-05-22 23:54 +0000
    RE: file I/O and arithmetic calculation Carlos Nepomuceno <carlosnepomuceno@outlook.com> - 2013-05-23 03:02 +0300

csiph-web