Photosynthesis is the process by which plants, algae, and some bacteria use sunlight, water and carbon dioxide to produce oxygen and energy in the form of ATP and NADPH. It occurs in two stages - the light-dependent reactions where energy from sunlight is captured and converted to chemical energy in ATP and NADPH, and the light-independent reactions where carbon dioxide is incorporated into organic compounds like glucose. There are different pathways for photosynthesis including C3, C4 and CAM which have evolved strategies to prevent the wasteful process of photorespiration.