In general, a piston is a sliding plug that fits closely inside the bore of a cylinder.
Its purpose is either to change the volume enclosed by the cylinder, or to exert a force on a fluid inside the cylinder.
Internal combustion engine
A piston in an internal combustion engine has some piston rings . Usually there are two compression rings as a seal between the piston and the cylinder wall, and one or more oil control rings below the compression rings. The head of the piston can be flat or bulged or otherwise shaped. Pistons can be forged or cast. The piston is an important component of a piston engine and of hydraulic and pneumatic systems.
In an Otto or Diesel engine, the head of the piston forms one wall of an expansion chamber inside the cylinder. The opposite wall, called the cylinder head, contains inlet and exhaust valves for gases.
As the piston moves inside the cylinder, it transforms the energy from the expansion of a burning gas (usually a mixture of petrol or diesel and air) into mechanical power (in the form of a reciprocating linear motion). From there the power is conveyed through a connecting rod to a crankshaft, which transforms it into a rotary motion, which usually drives a gearbox through a clutch.
External combustion engine
A steam engine is another type of piston engine. In most steam engines, the pistons are double acting: steam is alternately admitted to either end of the cylinder, so that every piston stroke produces power.