Explain the role of a diode in an electronic circuit.
A diode is a semiconductor device that primarily functions as a one-way switch for current. It allows current to flow easily in one direction but significantly restricts flow in the opposite direction. Diodes are commonly used for rectification, signal modulation, and voltage regulation.