# How to calculate molar mass using the ideal gas law?

It is found that 250 ml of a diatomic gas at standard temperature and pressure (STP) has a mass of 1.78 g. What is the diatomic gas?

How can this question be solved? I know that I am supposed to use the ideal gas law

$$pV = nRT,$$

but am not sure how to apply it to this question.

You can first use the ideal gas law to calculate $$n$$: \begin{align} pV &= nRT\\ (\pu{101325 Pa})(\pu{0.250 l}) &= n(\pu{8.314 J K-1 mol-1})(\pu{273 K})\\ \end{align}
Solving for "$$n$$" gives $$n = \pu{0.0111577 mol}$$.
Now we use the connection between mass $$m$$, amount of substance $$n$$, and molar mass mass $$M$$:
\begin{align} M &=\frac{m}{n}\\ n &=\frac{m}{M}\\ \pu{0.0111577 mol} &= \frac{\pu{1.78 g}}{M}, \end{align}
which gives a molar mass of $$M = \pu{159.53 g mol-1}$$.
Looking at the Periodic Table, we can identify the diatomic gas as being bromine gas ($$\ce{Br2}$$), which has a molar mass of $$\pu{159.8 g mol-1}$$.