How can transistors act as amplifiers or switches?

by creating two circuit loops