The Throttle Position Sensor (or "TPS") is an integral part of any electronically-controlled fuel system, even many carbureted systems. It is usually attached to one side of the butterfly valve which admits air into the intake manifold, while the throttle linkage is attached to the other. In carbureted systems, the throttle linkage may also have other functions; in fuel injected systems, it is the throttle position sensor which instructs the car as to how much fuel you are attempting to burn.
While fuel injection systems vary, in most cases the throttle position sensor's primary job is to report the position of the butterfly valve. The car is already capable of understanding whether it is running rich or lean via the oxygen sensor but it doesn't know what you're trying to do unless it has some way of understanding what position the pedal is in. While in a traditional carbureted vehicle the pedal position directly controls both air delivery (once the choke is open) and fuel delivery, in a fuel injected vehicle it controls only the throttle position sensor and the butterfly valve - if that! Vehicles with a drive-by-wire type throttle usually don't even have a throttle linkage, and instead connect only a spring and the throttle position sensor to the accelerator pedal. The air intake valve or valves are controlled by servomotor.
Throttle position sensors usually have three to five connector pins, and besides the throttle position may include an idle switch and/or a wide open throttle (WOT) switch.