Mega Code Archive

 
Categories / Python / Math
 

Built-in Numeric Tools

import math  print math.pi, math.e                                # Common constants print math.sin(2 * math.pi / 180)                    # Sine, tangent, cosine print math.sqrt(144), math.sqrt(2)                   # Square root print abs(-42), 2**4, pow(2, 4)  print int(2.567), round(2.567), round(2.567, 2)      # Truncate, round