Explanation
Molarity M = moles of solute / litres of solution
Molarity is moles of solute per litre of solution. Four grams of sodium hydroxide is a tenth of a mole.
In a quarter litre, that's zero point four molar.
Molarity M = moles of solute / litres of solution
Molality m = moles of solute / kg of solvent
Molality is moles per kilogram of solvent, not solution. Because it uses mass, it doesn't change with temperature.
Molarity does, because volume expands.
Molality m = moles of solute / kg of solvent
Mole fraction x = moles of one / total moles
Mole fraction is the share of moles. All the mole fractions in a solution add up to one.
Mole fraction x = moles of one / total moles; x₁ + x₂ = 1
Dilution
Adding water doesn't change the moles of solute. So molarity times volume stays the same before and after diluting.
Dilution: M₁V₁ = M₂V₂
Mixing
Mixing two solutions of the same solute: add up the moles, divide by the total volume.
Mixing: M = (M₁V₁ + M₂V₂) / (V₁ + V₂)
From % w/w and density
Bottle labels give percent by mass and density. Molarity equals percent times density times ten, divided by molar mass.
From % w/w and density: M = (% × d × 10) / molar mass
Worked example
18 g of glucose (M = 180) in 500 g of water. n = 0.
1 mol. Molality = 0.
1 / 0. 5 kg = 0.
2 m.