Flowers may appear purely ornamental, but their true function is to produce seeds, so the plant can reproduce itself. The reproductive parts of most flowers are enclosed within the petals. Most flowers have both male and female reproductive parts.
Male Reproductive Parts
The stamen is the portion of the flower that encompasses all its male reproductive organs. The stamen includes the anthers, which are the structures that produce and hold the flower's pollen grains, and the filaments, which are the stems that support the anthers. Generally, a single flower will have several anthers and filaments.
Female Reproductive Parts
The carpel or pistil encompasses all the female reproductive organs. At the very top of the pistil, the stigma is the place where pollinators like bees deposit pollen grains. Some flowers have multiple stigmas. In most flowers, the stigma is just level with or slightly above the anthers. The style is the neck of the pistil, a hollow tube that leads down to the flower's ovary at the base of the petals.
Pollen contains the male reproductive cells of the plant. The ovary encloses the ovules, which are the female reproductive cells.
Enclosing the reproductive organs of the flower are its petals, which have no overt sexual function, but which do play a role in reproduction by emitting scents that attract bees and other pollinating insects to the flower. The insects settle on the flower to gather the sweet nectar that the plant secretes; as they do so, they spread pollen that they've collected from other plants onto the stigmas of the flower.
When pollen lands on the stigma, the pollen grains put out tubes, which descend down the style to the ovary. Once there, the tubes release sperm cells that fertilize the ovules, which then develop into fruits that contain seeds.
Perfect and Imperfect Flowers
In horticultural terms, "perfect flowers" have both male and female reproductive organs. "Imperfect flowers" have only reproductive parts that are either male, or female. Some plants produce both male and female flowers, while others produce only male flowers, or only female flowers.