Force¶
- class Force(value: float | int, unit: str)¶
Bases:
UnitBaseForceobject.Attributes¶
Methods¶
to()It converts actual
valueto a new value computed usingtarget_unitas the reference unit of measurement.
- to(target_unit: str, inplace: bool = False) Force¶
It converts actual
valueto a new value computed usingtarget_unitas the reference unit of measurement.If
inplaceisTrue, it overrides actualvalueandunit, otherwise it returns a new instance with the convertedvalueand thetarget_unitasunit.Parameters¶
Returns¶
ForceConverted force.
Raises
Examples
Forceinstantiation.>>> from gearpy.units import Force >>> f = Force(1, 'N') >>> f 1 N
Conversion from newton to kilogram force with
inplace=Falseby default, so it does not override the current value.>>> f.to('kgf') 0.10197162129779283 kgf >>> f 1 N
Conversion from newton to kilogram force with
inplace=True, in order to override the current value.>>> f.to('kgf', inplace=True) 0.10197162129779283 kgf >>> f 0.10197162129779283 kgf