Molarity is an unit for expressing the concentration of a solute in a solution, and it is calculated by dividing the moles of solute by the liters of solution. Written in equation form, molarity = moles of solute / liters of solution.

**Calculate the moles of solute present**Calculate the number of moles from the given data by dividing the amount of solute by the molecular weight of the solute and multiplying it by 1 mol. For example, sodium hydroxide (NaOH) has a molecular weight of 40 g. So if a solution contains 20 g of NaOH, the moles of solute present is 0.5, and it's written as 0.5 mol NaOH.

**Calculate the number of liters of solution**If the volume of the solution is given in any unit other than liters, then convert that unit to liters of solution. For example, if a solution has a volume of 500 ml, converting it to liters of solution yields the result of 0.5 liters of solution, or 0.5 L solution.

**Calculate the molarity of the solution**After calculating the number of moles of solute and the liters of solution, divide the former by the latter to calculate the molarity of the solution. For example, if a 500 ml solution of NaOH contains 20 g of NaOH, the molarity of the solution is 1 M, or 1 mol/L.