Skip to content

Latest commit

 

History

History
77 lines (54 loc) · 2.4 KB

compounds.rst

File metadata and controls

77 lines (54 loc) · 2.4 KB

Chemical Compounds

Making a Compound

chemlib.chemistry.Compound

Instantiate a chemlib.Compound object with the formula of the compound.

>>> from chemlib import Compound >>> water = Compound("H2O") >>> water.formula 'H₂O₁'

chemlib.chemistry.Compound.occurences

A dictionary containing the frequencies of the constituent elements in the compound.

>>> water.occurences {'H': 2, 'O': 1}

Molar Mass

>>> water.molar_mass() 18.01

Percentage Composition by Mass

>>> water.percentage_by_mass('H') #Percent of Hydrogen in Compound 11.183 >>> water.percentage_by_mass('O') #Percent of Oxygen in Compound 88.834

Stoichiometry

Get the amount of moles and molecules of water given 2 grams of water.

>>> water.get_amounts(grams = 2) {'Compound': 'H₂O₁', 'Grams': 2, 'Moles': 0.111, 'Molecules': 6.685e+22}

Get the amount of grams and molecules of water given 2 moles of water.

>>> water.get_amounts(moles = 2) {'Compound': 'H₂O₁', 'Grams': 36.02, 'Moles': 2, 'Molecules': 1.204e+24}

Get the amount of moles and grams of water given 2e+24 molecules of water.

>>> water.get_amounts(molecules = 2e+24) {'Compound': 'H₂O₁', 'Grams': 59.834, 'Moles': 3.3223, 'Molecules': 2e+24}