Open in CoCalc with one click!

Pint Python Library

Pint is a Python package to define, operate and manipulate physical quantities: the product of a numerical value and a unit of measurement. It allows arithmetic operations between them and conversions from and to different units.

http://pint.readthedocs.io/

In [2]:
import pint pint.__version__
'0.8.1'
In [3]:
ureg = pint.UnitRegistry() 3 * ureg.meter + 4 * ureg.cm
3.04 meter
In [4]:
import numpy as np np.array([3, 4]) * ureg.meter + np.array([4, 3]) * ureg.cm
(3.044.03)meter\begin{pmatrix}3.04 & 4.03\end{pmatrix} meter
In [8]:
Q_ = ureg.Quantity temp1 = Q_(25.4, ureg.degC) temp1.to('degF')
77.72000039999993 degF
In [ ]: