Your lungs bring fresh oxygen into your body. They remove the carbon dioxide and other waste gases that your body's doesn't need.
To breathe in (inhale), you use the muscles of your rib cage- especially the major muscle, the diaphragm. Your diaphragm tightens and flattens, allowing you to suck air into your lungs. To breathe out (exhale), your diaphragm and rib cage muscles relax. This naturally lets the air out of your lungs.
To get the oxygen your body needs, you inhale air through your mouth and nose. The mucous membranes in your mouth and nose warm and moisten the air, and trap particles of foreign matter (like dirt and dust). The air passes through the throat into the trachea (windpipe).
The trachea divides into the left and right bronchi. Like a branch, each bronchus divides again and again, becoming narrower and narrower.
Your smallest airways end in the alveoli, small, thin air sacs that are arranged in clusters like bunches of balloons. When you breathe in by enlarging the chest cage, the "ballons" expand as air rushes in to fill the vacuum. When you breathe out, the "balloons" relax and air moves out of the lungs.
Tiny blood vessels surround each of the 300 million alveoli in the lungs. Oxygen moves across the walls of the air sacs, is picked up by the blood and carried to the rest of the body. Carbon dioxide or waste gas passes into the air sacs from the blood and is breathed out.
This is how oxygen and carbon dioxide cycle takes place in humans