chemhelper.conversions
chemhelper.conversions ¶
Conversions between grams, moles and molarity.
grams_to_moles ¶
Convert a mass of a substance to moles.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mass
|
float
|
Mass of the sample in grams. |
required |
chemical
|
str
|
Chemical formula of the substance. |
required |
Returns:
| Type | Description |
|---|---|
float
|
Moles, rounded to 2 decimals. |
Examples:
Source code in src/chemhelper/conversions.py
grams_to_moles_steps ¶
Print the grams-to-moles conversion.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mass
|
float
|
Mass of the sample in grams. |
required |
chemical
|
str
|
Chemical formula of the substance. |
required |
Examples:
Source code in src/chemhelper/conversions.py
moles_to_grams ¶
Convert moles of a substance to grams.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
moles
|
float
|
Amount of substance in moles. |
required |
chemical
|
str
|
Chemical formula of the substance. |
required |
Returns:
| Type | Description |
|---|---|
float
|
Mass in grams, rounded to 2 decimals. |
Examples:
Source code in src/chemhelper/conversions.py
moles_to_grams_steps ¶
Print the molar mass calculation and the moles-to-grams conversion.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
moles
|
float
|
Amount of substance in moles. |
required |
chemical
|
str
|
Chemical formula of the substance. |
required |
Source code in src/chemhelper/conversions.py
molarity ¶
Molarity (moles of solute per liter of solution).
Give either moles, or mass together with chemical.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
volume
|
float
|
Volume of solution in liters. |
required |
mass
|
float
|
Mass of solute in grams. |
None
|
chemical
|
str
|
Chemical formula of the solute (required with |
None
|
moles
|
float
|
Moles of solute. |
None
|
Returns:
| Type | Description |
|---|---|
float
|
Molarity in mol/L. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If neither |
Examples:
Source code in src/chemhelper/conversions.py
molarity_steps ¶
Print a step-by-step molarity calculation.
Takes the same arguments as :func:molarity.
Source code in src/chemhelper/conversions.py
molarity_to_moles ¶
Moles of solute in a volume of solution.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
M
|
float
|
Concentration in mol/L. |
required |
volume
|
float
|
Volume of solution in liters. |
required |
Returns:
| Type | Description |
|---|---|
float
|
Moles of solute. |
Examples:
Source code in src/chemhelper/conversions.py
molarity_to_moles_steps ¶
Print the molarity-to-moles conversion.
Takes the same arguments as :func:molarity_to_moles.
Source code in src/chemhelper/conversions.py
molarity_to_grams ¶
Grams of solute in a volume of solution.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
molarity
|
float
|
Concentration in mol/L. |
required |
volume
|
float
|
Volume of solution in liters. |
required |
chemical
|
str
|
Chemical formula of the solute. |
required |
Returns:
| Type | Description |
|---|---|
float
|
Mass of solute in grams, rounded to 2 decimals. |
Examples:
Source code in src/chemhelper/conversions.py
molarity_to_grams_steps ¶
Print the molarity-to-grams conversion.
Takes the same arguments as :func:molarity_to_grams.