Chemists define a mole of a compound as Avogadro's number of molecules of that compound. You can use this information to calculate the number of moles in a sample of a compound with a known weight or mass. Conversely, if you know the number of moles of the compound you have, you can calculate the weight or mass of the sample. These calculations apply whether the compound is a solid, liquid or gas, but to perform either of them, you need to know the molecular mass of the compound. As long as you know the chemical formula of the compound, you can look up its molecular mass.
TL;DR (Too Long; Didn't Read)
To find the number of moles of a compound you have on hand, look up the molecular weight of the compound and divide that number into the weight you have on hand. If you know the number of moles, you can find the weight by multiplying the number of moles by the molecular weight.
About Mass and Weight
In chemistry, you often see the words mass and weight used interchangeably. Although weight is a measure of the force of gravity on an object while mass is the amount of matter it contains, the two quantities are essentially equivalent, as long as as all measurements are performed in Earth's gravitational field. If you perform experiments in space though, the distinction becomes important. In the metric system, the units for mass and weight are the same: gram and kilogram.
Determining Molecular Weight
Every compound is a collection of atoms, and each atom has a characteristic weight. It's displayed under the atoms symbol in the periodic table. For example, the atomic weight of hydrogen is 1.008 (usually rounded to 1) and that of oxygen is 15.999 (usually rounded to 16). A water molecule (H2O) contains two hydrogens and an oxygen, so the molecular weight of water is 18. The units of mass are atomic mass units, which when considering macroscopic amounts, are equivalent to grams/mole.
Example: What is the molecular weight of baking soda (sodium bicarbonate)?
The chemical formula for sodium bicarbonate is NaHCO3. A molecule contains 1 sodium atom (atomic weight 23), 1 hydrogen atom (atomic weight 1), 1 carbon atom (atomic weight 12) and 3 oxygen atoms (atomic weight 16). Adding these together, you get the molecular weight of sodium bicarbonate, which is 23 + 1 + 12 + (3 • 16) = 84 grams/mole.
Determining Number of Moles of a Compound With Known Mass
Once you've found the molecular weight, you know the weight of one mole of a compound. To find the number of moles in a sample, simply weigh it and divide the weight by the molecular weight. The quotient is equal to the number of moles.
Example: How many moles are there in 300 grams of sodium bicarbonate?
The molecular weight of sodium bicarbonate is 84 grams/mole. Divide this number into the weight on hand to find the number of moles: 300 grams ÷ 84 grams/mole = 3.57 moles.
Determining Weight of a Known Number of Moles of a Compound
If you know how many moles you have of a compound, you can find how much the compound weighs. All you have to do is to multiply the molecular weight by the number of moles you have on hand.
Example: How much do 7 moles of sodium bicarbonate weigh?
The weight of one mole is 84 grams, so the weight of 7 grams is 588 grams, or 0.588 kilograms.