Ver Mensaje Individual
  #1 (permalink)  
Antiguo 26/11/2010, 02:10
REHome
 
Fecha de Ingreso: mayo-2007
Ubicación: PIC-16F84A
Mensajes: 727
Antigüedad: 16 años, 10 meses
Puntos: 8
Convertir de negativo a positivo.

Hola:

Quiero convertir los números negativo a positivo. Estoy usando este ejemplo que he modificado cuando vi otros ejemplos por aquí.

http://www.forosdelweb.com/f130/dife...tiguos-730591/
http://www.forosdelweb.com/f16/numer...sitivo-418002/

Código Python:
Ver original
  1. a=[1, 3, 6, 10]
  2.  
  3. def restar_valores(lista):
  4.     """ resta los valores de la lista"""
  5.    
  6.     for x in range(len(lista)-1):
  7.         print "la resta de %s y %s es igual a %s " % (lista[x],
  8.                                                       lista[x+1],
  9.                                                       lista[x] - lista[x+1])
  10.  
  11. restar_valores(a)

Saludo.
__________________
Meta Shell, VERSIÓN 1.2.2
Descargar