A transistor is a semiconductor device used to amplify or switch electronic signals and electrical power. It is one of the most important building blocks of modern electronic circuits.
A transistor controls the flow of current — it can allow or block current depending on the input signal applied to it.
In simple words, it works like an electronic switch or amplifier.