Advertisement
elcocodrilotito

maximo ficheros

Nov 24th, 2016
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.47 KB | None | 0 0
  1. """Escribir una función que tome como argumento un fichero. En cada línea del fichero habrá un número entero (negativo o positivo).
  2. La función leerá todos los números y devolverá el máximo"""
  3.  
  4. def maximo(fichero):
  5.     fp=open(fichero)
  6.     linea=fp.readline()
  7.     a=int(linea)
  8.     while linea:
  9.         b=int(linea)
  10.         print(b)
  11.         if a<b:
  12.             a=b
  13.         linea=fp.readline()
  14.     fp.close()
  15.     return a
  16. print(maximo("maximo ficheros.txt"))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement