Your sex characteristics were determined by X and Y chromosomes, same as most other creatures from humans to fruit flies. So why do birds and butterflies have ZW chromosomes instead? And more importantly, why does ZW produce a female bird while ZZ produces a male?
The XY and ZW Systems of Sex Determination
Birds, butterflies, and snakes take everything we know about sex at the chromosomal level and stand it on its head. Instead of X and Y chromosomes, they have Z and W chromosomes.
What's the difference? Everything. The XY and ZW chromosomes share no genes at all. What's more, the ZW chromosomes flip the sex determination system. A male chicken - or peacock, or giant river prawn, or komodo dragon - has a ZZ chromosome. A female has a ZW chromosome.
There are a few traits in ZW and XY systems that are analogous. The Y chromosome has shrunk and changed over time, and the W chromosome has done the same. Ratites, an ancient class of birds, which originated on the supercontinent Gondwana and which contains ostriches and casowaries, have Z and W chromosomes that closely resemble each other. Birds that have made a relatively recent appearance have wildly different Z and W chromosomes. The W chromosome has shriveled up over the years.
For both XY and ZW systems, there are all kinds of variations on what happens if one gene is missing or doubled. In mammals, an XO (an X chromosome and a missing chromosome) usually results in a female. When it comes to fruit flies or crickets, a single X chromosome results in a male. So sometimes the presence of a Y is required to produce a male, and sometimes it isn't. There haven't been any ZO birds found, indicating they need at least two chromosomes to develop, but ZO, ZZW and ZZWW all produce female butterflies. Snakes added to the confusion recently, when a female python produced offspring despite not having been near any males. This parthenogenesis produced all-female offspring with WW chromosomes — a combination not previously thought possible.
How and Why Did This Happen?
In one system males are heterogametic, with XY chromosomes, and in the other system they are homogametic, with ZZ chromosomes. How did such a dramatic reversal come to exist?
No one is sure why, but one theory points to strenuous male competition in animals with the the ZW system. There's sexual competition in most species, of course, but XY males compete in a way that demonstrates overall fitness, while ZZ males compete in a way that demonstrates traits which make them fit as a male, but would be disastrous for females. The most dramatic example is the peacock. The males' stunning tails help them attract mates, but if the tail were inherited by a female it would get her eaten by a predator. Meanwhile, male pythons may have a mating advantage if they're comparatively smaller than female pythons, but female pythons are better off if they're big and strong.
Look at a male peacock's genes. Let's say a male peacock had XY sex chromosomes, and had the genes for his beautiful tail embedded on his X chromosome. Even if he got to mate, his fabulous tail would only go to his daughters. If he has the genes on his Z chromosome — the larger and more extensive chromosome — and he's a ZZ homogamete, then half of his sons get the genes for the tail that allowed him to breed.
Under this theory, being homogametic allows males to make more extensive displays of their maleness, and lets females be choosy as to which males to mate with. On the other hand, ZW females are vulnerable to genetic defects, and XX females are more robust, which is why traits like hemophilia and adrenoleukodystrophy are rarely expressed in human, or any other homogametic, females.
As to how it happened, that's still an unanswered question. Most scientists believe that the XY and ZW systems diverged only once. The fact that mix-ups in sex chromosomes so often produce nonviable or sterile offspring mean that the flip probably couldn't have happened multiple times across many different species.
However, there are those who disagree. There is evidence that not all the XY-ZW flips occurred at the same time. While the bird W chromosome has degraded over a long period of time, the fish W chromosome appears to have minimal differences from the Z chromosome — indicating that these ZW chromosomes are relatively new and haven't had time to diverge.
And Then There's the Platypus
And just when everyone thought that sex determination was complicated enough, in came the platypus. The mammal that has been confusing people for centuries had its genes analyzed, and threw researchers for a loop by having links to both XY and ZW systems.
Platypus have five male-specific chromosomes (Y chromosomes) and five chromosomes present in one copy in males and two copies in females (X chromosomes). These ten chromosomes form a multivalent chain at male meiosis, adopting an alternating pattern to segregate into XXXXX-bearing and YYYYY-bearing sperm. Which, if any, of these sex chromosomes bears one or more sex-determining genes remains unknown. The largest X chromosome, with homology to the human X chromosome, lies at one end of the chain, and a chromosome with homology to the bird Z chromosome lies near the other end. This suggests an evolutionary link between mammal and bird sex chromosome systems, which were previously thought to have evolved independently.
So good luck with that, science.
[Sources: A New Look at the Evolution of Avian Sex Chromosomes, Evidence for Viable, Non-Clonal but Fatherless Boa Constrictors, Chromosomal Sex Determination in Drosophila, Population Genetics: XYZW as Nature's Language of Love?, Relationships Between Vertebrate XY and ZW Sex Chromosome Systems, In the Platypus.]