Ver Mensaje Individual
  #2 (permalink)  
Antiguo 26/11/2010, 09:41
Avatar de razpeitia
razpeitia
Moderador
 
Fecha de Ingreso: marzo-2005
Ubicación: Monterrey, México
Mensajes: 7.321
Antigüedad: 19 años, 1 mes
Puntos: 1360
Respuesta: Convertir de negativo a positivo.

Si quieres convertir un numero negativo a positivo puedes usar la funcion abs en el modulo math.
Código Python:
Ver original
  1. import math
  2. print math.abs(-3)

O puedes hacer un simple if
Código Python:
Ver original
  1. if x < 0:
  2.     x = -x