Chemistry - How to calculate the molarity of a gas?
Solution 1:
Molarity is defined as "moles of solute per volume of solution", which implies that the system is in the liquid state.
As such, molarity is undefined for anything in a gaseous state -- there is no solute/solvent distinction in the gas phase.
You can define the concentration of a gas, though, and that calculation would be exactly the one you've described: placing $X$ moles of a gas in a container of volume $V$ yields a concentration $C=X/V$, with units of, e.g., $\pu{mol\over dm^3}$.
Note that while these units might look the same as the units of molarity, they are different. In this concentration value, the volume is the volume of the container; in a molarity value, the volume is the volume of the solution.
Solution 2:
The answer given by hBy2Py is correct - "only solutions have molarity" is likely the right thing to say on the quiz. It will help you remember that in calculations of equilibrium constants and Nernst potentials, gases are referenced to a standard pressure rather than a concentration, and that pressure corresponds to 1 bar at 0 C = 1 mol / 22.7 L, not 1 mol/L.
But ... that answer is also wrong, and here's why.
Many modern texts define "solutions" to include mixtures of gases. By that semantics, you correctly described the molarity of a solution in your question.
It is commonly said and often useful to know that water at STP is 55.5 mol/L. Though converting this to a vapor normally involves boiling and a visible change of state, we also have the option to pressurize it to 300 atm, heat to 700 K, then lower the pressure. This goes around the critical point on the phase diagram. Although subtle and interesting boundaries between supercritical liquid and supercritical gas can be drawn, there is no point on that path at which we would feel a sudden need to stop using mol/L to report the moles of water per liter. In a study of hydrothermal water you might need to work in any region of the phase diagram along that path using consistent terms.
Most importantly, thinking about the concentration of gases can help you to understand the colligative properties of solutions. For example, the ideal gas law PV = nRT can be rewritten as P = cRT, where c = n/V is the concentration of the gas as you defined it. That is the same formula as we use (at first approximation, and remembering some substances dissociate into multiple moles of particles) to determine the osmotic pressure of a solution! It takes some doing to understand how these relate to the thermal energy of individual particles, but by regarding the situations side by side you will have an easier time of it.