Welcome to this Python challenge! This time, we are going to help a florist compose beautiful, colourful bouquets for their customers. Your task is to write a Python program that recommends different flowers based on the colours the customer wants and the number of different flowers they would like in their bouquet.
The program should:
- Ask the user for the colours they want in their bouquet.
- Ask the user for the number of different flowers they want in their bouquet.
- Suggest a selection of flowers that match the requested colours and number.
For instance, if the user wants a red, purple and yellow bouquet with 5 different types of flowers, the program might suggest:
- Red Tulips
- Red Poppies
- Purple Wisteria
- Purple Orchids
- Yellow Daffodils
Getting Started
To complete this challenge we will use a dictionary data structure. The keys of our dictionary will be the different colours. For each colour, our dictionary will store a list of flowers matching the colour.
Here’s our dictionary data structure called flowers:
flowers = { "Red": ["Rose", "Tulip", "Carnation", "Geranium", "Poppy", "Amaryllis", "Anemone", "Camellia"], "Purple": ["Lilac", "Orchid", "Lavender", "Allium", "Clematis", "Bellflower", "Iris", "Wisteria"], "Yellow": ["Sunflower", "Daffodil", "Marigold", "Dahlia", "Tulip", "Buttercup", "Goldenrod", "Forsythia"], "Blue": ["Bluebell", "Cornflower", "Delphinium", "Hydrangea", "Iris", "Periwinkle", "Forget-me-not", "Agapanthus"], "White": ["Lily", "Jasmine", "Daisy", "Gardenia", "Baby's Breath", "Magnolia", "Peony", "Snowdrop"], "Pink": ["Peony", "Cherry Blossom", "Azalea", "Carnation", "Begonia", "Camellia", "Dahlia", "Foxglove"], "Orange": ["Marigold", "Zinnia", "Nasturtium", "Buttercup", "Bird of Paradise", "Calendula", "Geum", "Tiger Lily"], "Green": ["Green Rose", "Bells of Ireland", "Green Hydrangea", "Green Zinnia", "Green Carnations", "Green Chrysanthemum"], "Black": ["Black Dahlia", "Black Rose", "Black Callas", "Black Pansy", "Black Tulip"], "Brown": ["Chocolate Cosmos", "Brown-Eyed Susan", "Cattail", "Brown Orchid"] }
Python Code
Here’s a basic outline of how your program might look:
-
Input: Ask the user for the colours and the number of flowers.
Process: Use the input to select flowers from your dictionary. Randomly selecting flowers from the list for a given colour will provide more variety in the suggestions made by your program.
Output: Print the suggested bouquet.

Solution...
The solution for this challenge is available to full members!Find out how to become a member:
➤ Members' Area