Python math and money
Calculate a change in temperature, pack boxes, or round a bill.
Everyday arithmetic and rounding
- absIn Python, abs returns the magnitude of a number.
- math.ceilIn Python, math.ceil rounds toward positive infinity.
- math.floorIn Python, math.floor rounds toward negative infinity.
- Decimal.quantizeRound invoice lines to a currency unit
- math.gcdPack two ribbon lengths into equal pieces
- maxKeep enough seats for a booking
- mean and fsumPredict a delivery charge from past orders
- minCap a voucher at the total due
- random.randomCheck the range of a practice draw
- roundDisplay a delivery estimate in minutes
- statistics.quantilesFind the upper quartile of checkout times
Powers, roots, and logarithms
- math.expCheck the baseline of a growth model
- math.expm1Recover a small percentage increase
- math.logMeasure the continuous growth needed to double
- math.log10Count orders of magnitude in a reading
- math.log1pConvert a small growth rate accurately
- math.powProject repeated doubling
- math.sqrtFind the side of a square garden
Angles and distances
- math.acosRecover the angle of an awning arm
- math.asinRecover a ladder angle from its height
- math.atanTurn a ramp slope into an angle
- math.atan2Find a direction on a map
- math.cosFind the horizontal reach of an awning
- math.coshEstimate the shape of a hanging cable
- math.degreesLabel a quarter turn in degrees
- math.hypotMeasure the diagonal of a screen
- math.radiansConvert a half turn into radians
- math.sinFind the vertical share of a ladder
- math.sinhEstimate the slope of a hanging cable
- math.tanCalculate rise per metre of horizontal run
- math.tanhSmooth a strong sensor signal
Integer arithmetic and overflow
Floating-point precision
- math.copysignApply a refund direction to an amount
- math.isfiniteReject unusable sensor readings
- math.ldexpUndo a power-of-two sensor scale
- math.nextafterTest just below a measurement limit
- math.nextafterTest just above a measurement limit
- math.remainderFind a short signed turn
- math.ulpInspect the resolution of a sensor calculation