Pint
Revision as of 22:30, 5 December 2018 by Hdridder (talk | contribs) (Created page with "Category:Python This code make all kind of units available as UNITS.unit: <syntaxhighlight lang=python> import pint UNITS = pint.UnitRegistry() Quantity = UNITS.Quantity...")
This code make all kind of units available as UNITS.unit:
import pint
UNITS = pint.UnitRegistry()
Quantity = UNITS.Quantity
You can specify formulas with units.
The formula for gravity acceleration:
meter = UNITS.meter
second = UNITS.second
acc = 9.8 * meter / second ** 2
time = 9 * second
speed = acc * time
print(speed)
Output:
88.2 meter / second