P-traps play a crucial role in plumbing systems by preventing the entry of foul odors and sewer gases into living spaces. These traps are typically U-shaped or S-shaped pipes that hold a small amount of water, creating a barrier against unwanted gases. The size of a p-trap is crucial to ensure proper functioning. Various plumbing codes specify the minimum size for p-traps based on the type of fixture they serve. Understanding these code requirements and selecting the appropriate p-trap size is vital to maintain a safe and effective plumbing system.