[Tutor] Lance E Sloan"help"
Morne
Morne" <fromclay@maxitec.co.za
Wed, 21 Aug 2002 15:33:53 +0200
This is a multi-part message in MIME format.
------=_NextPart_000_0085_01C24928.27921600
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
Lance E Sloan
Hi=20
No this is not a class im taking but my boss , he is a Delphi and Unix =
and python expert and he wants me to do this project
I have tried some code but cant seem to get started and by friday it =
must be done.
here is what i have=20
# line/word counter =20
def getStuff(file):
info =3D open(file, 'r')
infolines =3D info.readlines()
linenum =3D 1
for line in infolines:
words =3D line.split(' ')
print "Line %d contains %d words" % (linenum, len(words))
linenum +=3D 1
file =3D raw_input("Enter the filename: ")
getStuff(file)
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx=
xxxxxxxxxxxxxxx
here is what I need to do
c I need to reate a Python program that takes a text file and counts the =
number of
lines in the file, the number of words in a line and then produces a
summary. The Output must look like this.
Enter file name:
> testfile.txt
LINE# WORDS
--------------------
1 20 words
2 25 words
3 30 words
4 25 words
--------------------
Summary:
4 lines, 100 words, Avg: 25 words/line
Please let me know soon
Morne
------=_NextPart_000_0085_01C24928.27921600
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META content=3D"text/html; charset=3Diso-8859-1" =
http-equiv=3DContent-Type>
<META content=3D"MSHTML 5.00.2614.3500" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>Lance E Sloan<BR></FONT></DIV>
<DIV><FONT face=3DArial size=3D2>Hi </FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>No this is not a class im taking but my =
boss , he=20
is a Delphi and Unix and python expert and he wants me to do this=20
project</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>I have tried some code but cant seem to =
get started=20
and by friday it must be done.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>here is what i have </FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2># line/word counter <BR><BR>def=20
getStuff(file):<BR> info =3D open(file,=20
'r')<BR> infolines =3D =
info.readlines()<BR> =20
linenum =3D 1<BR> for line in=20
infolines:<BR> words =3D =
line.split('=20
')<BR> print "Line %d contains =
%d=20
words" % (linenum, =
len(words))<BR> =20
linenum +=3D 1<BR><BR>file =3D raw_input("Enter the filename:=20
")<BR>getStuff(file)</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial=20
size=3D2>xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx=
xxxxxxxxxxxxxxxxxxxxxxxx</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>here is what I need to do</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2><BR>c I need to reate a Python program =
that takes a=20
text file and counts the number of<BR>lines in the file, the number of =
words in=20
a line and then produces a<BR>summary. The Output must look like=20
this.<BR><BR><BR>Enter file name:<BR>> =
testfile.txt<BR><BR><BR>LINE# =20
WORDS<BR>--------------------<BR>1 20=20
words<BR>2 25=20
words<BR>3 30=20
words<BR>4 25=20
words<BR>--------------------<BR>Summary:<BR>4 lines, 100 words, Avg: 25 =
words/line</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>Please let me know soon</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>Morne</FONT></DIV>
<DIV><FONT face=3DArial size=3D2><BR> </DIV></FONT></BODY></HTML>
------=_NextPart_000_0085_01C24928.27921600--