Both flagella and pili are extensions from the bacterial cell body. Flagella are like a whip or a tail while pili are best described as hairlike. Flagella actually extend from the interior of the cell body while cili are strictly surface appendages. They are also made up of different proteins, flagellin (for flagella) and pilin (for pili). Finally, they serve different purposes for the cell. Flagella are used primarily for propulsion and movement but can also be used to sense certain chemcals and temperature. Pili are used more for surface recognition and can allow certain bacteria to come together and exchange DNA with one another.