Lung function is to enable respiration, which is the transfer of cases between the blood and your lungs. In order to achieve this your lungs must use inspiration and expiration. For inspiration (inhale) to occur, many muscles are contracted, such as the diaphragm, intercostals, and pectorals, causing a decrease in air pressure within the lungs. This then forces air from the atmosphere to move into the lungs to balance the pressure. As the air comes into the body it is warmed by the blood vessels close to the surface in the respiratory system and moistened by the mucus lining the walls. This helps to increase gas exchange and makes breathing more comfortable.

Another aspect of lung function is expiration (exhale). Expiration requires that the body increases the pressure in the lungs in order to push air out of the lungs, although complete emptying of the lungs does not happen as this would cause a suction to occur, which would make it difficult to inspire again. The trachea, bronchi and bronchioles are also kept open by cartilage to ensure the airway does not close, but remains open to make breathing easier. Expiration is achieved through the elastic properties of the lungs and thoracic cage, as well as contraction of the intercostal muscles. This increases the air pressure in the lungs pushing the air out into the atmosphere.

During exercise or physical activity, the lung function is to increase the respiratory rate in order to increase the volume of air moving in and out of the lungs per minute. The volume of air inspired and expired also increases in response to physical activity in order to increase the oxygen absorbed through the alveoli and carbon-dioxide expelled from the body.

The video below talks more about lung function and respiration and the various processes that occur during inspiration and expiration. It also provides a nice visual of the lungs inflating and deflating during the respiratory process. This should provide you with a deeper understanding of lung function.