When ventilating second story bathrooms, the duct is always located in the attic. In most cases duct in the attic is not insulated and is made from a flexible hose which comes with a Duct Kit, or if installed by HVAC contractor, they use a sheet metal duct as you see in most basement used in your heating system. The vent in the attic which runs directly to the outside, allows bath fan remove large amount of moisture which is generated from taking showers or baths.
Since bath fans help fight accumulating mold inside the bathroom by removing large amount of moisture, especially fans which wired directly to the light and run each time the light is turned on. it is very important to have the duct in the attic to be insulated. The reason for that is because the moist air that the duct carries is moist and contains water, in the winter time when warm moist air enters a cold duct, the air turns into dew and it will will create puddles in the ductwork because warm air holds more moisture than cold air does. Therefore the water will collect and sit inside the duct, over time will cause corrosion and lead to more costly repairs.
So if you changing a fan or installing a new one, make sure the installer or DIY Homeowner, insulated duct is being used, or the duct is pitched thoughts the discharge opening so the water is being able to drain without getting trapped and puddle the duct.