🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: es.comp.os.linux.programacion
Article #8001

Re: Leer un fichero

#8001
From: Eru
Date: Fri, 03 Jan 2003 22:28
35 lines
1786 bytes
DK <ionidk@terra.es> escribio:
> Pues yo no me quedo sin ponerlo en Python:

## Inicio del programa

#!/usr/bin/env python2.2
import sys

dec=2

total = 0
num = 0


f = open(sys.argv[1],'r')
for l in f:
    num+=1
    total+=float(l)
print round(total/num,dec)

## Fin del programa

$ ./media.py numeros.txt 
32.36

Hala, ahora lanzo el pique...quien se atreve a hacerlo en brainfuck? 
(leyendo de la entrada estandard)
Yo no me veo con fuerzas, que el atoi() del bf es infernal...y la 
division no quiero ni imaginarmela

-- 
Daniel Ripolles ( Eru )
+[>>>+++++++[<++++++++++>-]<-.>+++++
[<+++++++++>-]<.+++.[-]>++++
[<++++++++>-]<.<<+]++++++++++.
Technical Details
Message-ID: <av52r1$dsm$1@sofora01.uji.es>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!logbridge.uoregon.edu!newspeer1.nac.net!news.stealth.net!news.stealth.net!news.astraweb.com!news-small.astraweb.com!news-out.spamkiller.net!propagator2-maxim!news-in.spamkiller.net!news.telia-iberia.com!news.rediris.es!news.uv.es!sofora01.uji.es!not-for-mail
References: <7d4ff0e4.0301020707.6388a1a6@posting.google.com>

Show Full Headers
Complete Article Headers
X-Google-Language: SPANISH,ASCII-7-bit
X-Google-Thread: f86c8,5cf283a7acb0d167
X-Google-Attributes: gidf86c8,public
X-Google-ArrivalTime: 2003-01-03 14:38:05 PST
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!logbridge.uoregon.edu!newspeer1.nac.net!news.stealth.net!news.stealth.net!news.astraweb.com!news-small.astraweb.com!news-out.spamkiller.net!propagator2-maxim!news-in.spamkiller.net!news.telia-iberia.com!news.rediris.es!news.uv.es!sofora01.uji.es!not-for-mail
From: Eru <ripolles@LALALAaditel.org>
Newsgroups: es.comp.os.linux.programacion
Subject: Re: Leer un fichero
Date: Fri, 3 Jan 2003 22:28:49 +0000 (UTC)
Organization: Universitat Jaume I
Lines: 35
Sender: Daniel Ripollés Climent <ripolles@devnull.aditel.org>
Message-ID: <av52r1$dsm$1@sofora01.uji.es>
References: <7d4ff0e4.0301020707.6388a1a6@posting.google.com>
NNTP-Posting-Host: devnull.cent.uji.es
X-Trace: sofora01.uji.es 1041632929 14230 150.128.184.125 (3 Jan 2003 22:28:49 GMT)
X-Complaints-To: news@marti.uji.es
NNTP-Posting-Date: Fri, 3 Jan 2003 22:28:49 +0000 (UTC)