Ver Mensaje Individual
  #1 (permalink)  
Antiguo 20/07/2011, 13:57
andrade_dex
 
Fecha de Ingreso: julio-2011
Mensajes: 7
Antigüedad: 12 años, 9 meses
Puntos: 0
funciones en Phyton

Hola atodos

soy nuevo en python que deseo su ayuda

tengo el siguiente codigo
lo que hace es pedir nombre y la estatura se detiene y muestra la lista al digitar exit, como lo puedeo hacer mediante funciones
una funcion para pedir nombre y estatura y otra funcion que la estatura la convierta en pulgadas y que mustre los datos

gracias

Código Python:
Ver original
  1. def main():
  2.     people = []
  3.     while True:
  4.         name = raw_input("your name (type 'exit' to quit)>>")
  5.         if name == 'exit':
  6.             break
  7.         height_meters = raw_input('your height (in meters)>>')
  8.         height_inches = float(height_meters) * 100 / 2.54
  9.         person = {
  10.             'Name': name,
  11.             'HeightMeters': height_meters,
  12.             'HeightInches': height_inches,
  13.         }
  14.        
  15.     people.append(person)
  16.  
  17.         print
  18.         print "next..."
  19.         print
  20.  
  21.     for person in people:
  22.         print "Name: %(Name)s, Height in meters: %(HeightMeters)s, Height in inches: %(HeightInches)0.2f" % person
  23.  
  24.  
  25. if __name__ == '__main__':
  26.     main()

Última edición por razpeitia; 20/07/2011 a las 14:42 Razón: Resaltado de sintaxis