Energy supplied to a gas as heat can do two things: raise its internal energy, or let it do work by pushing back a piston. The first law of thermodynamics keeps the books: the rise in internal energy equals the heat added plus the work done on the gas. Set the heat and the expansion, and watch the ledger balance.