How are the lungs and capillaries involved in gas exchange ?
When you inhale air, it follows a very specific pathway into the lung cavity. Nose to nasal cavity, to pharynx, to layrnx, to trachea, to one of two bronchi, into tiny little alveoli. Air never actually fills the lungs. The air stays within the above listed tubes. Each lung contains about 300 million alveoli, which are small air sacs. They sort of look like grapes on a vine, and they give the lungs about 6 liters of total air capacity.
Each alveoli is surrounded/encased in a "net" of capillaries. Blood from the right side of heart is pumped through those blood vessels. That blood is poor in oxygen and rich in carbon dioxide. Because you just inhaled, the alveoli are filled with air that is rich in oxygen and poor in carbon dioxide. That means there is a concentration difference between the capillaries and alveoli. Because of that difference, the passive transport mechanism diffusion begins to work. Carbon dioxide diffuses from the capillaries to the alveoli, and oxygen diffuses from the alveoli to the capillaries. The blood, which is now oxygen rich, is pumped back to the heart for redistribution to the rest of the body. The air in the alveoli is full of carbon dioxide and is exhaled along the same pathway that it was originally inhaled through.