The Allotment Crop Planner (Python Challenge)

In this challenge, we will work with a JSON dataset containing detailed information about crops that can be grown in an allotment. The dataset includes, soil types, watering needs, and more.

Your task is to write a Python program that helps an allotment gardener by answering specific questions about what they can grow and when.

Learning Objectives

By completing this challenge you will improve your python skills and learn to:

  • Load a JSON dataset using the json module.
  • Use loops on lists and dictionaries data structures to filter crops based on user input.
  • Convert user input (month, soil type, etc.) to a standard format to avoid case-sensitivity issues.

The JSON Dataset

Here is a sample of the dataset that your program will use:

{
  "allotment_crops": [
    {
      "name": "Carrot",
      "type": "Vegetable",
      "planting_season": ["March", "April", "May", "June", "July"],
      "harvest_season": ["June", "July", "August", "September", "October"],
      "soil_type": "Light, sandy, well-drained",
      "sunlight": "Full sun",
      "watering_needs": "Moderate",
      "container_friendly": true
    },
    {
      "name": "Tomato",
      "type": "Fruit",
      "planting_season": ["March", "April", "May"],
      "harvest_season": ["July", "August", "September"],
      "soil_type": "Rich, well-drained",
      "sunlight": "Full sun",
      "watering_needs": "Regular",
      "container_friendly": true
    }
  ]
}

(The full dataset is provided in a separate json file in the Python IDE below.)

Python Challenges

To complete this project, you will need to complete all 5 challenges listed in the tabs below:

Challenge 1: Crops to Plant This MonthChallenge 2: Crops to Harvest This MonthChallenge 3: Container-Friendly CropsChallenge 4: Best Crops for Your GardenChallenge 5: Interactive Crop Assistant

Challenge 1: Crops to Plant This Month

The aim of this first challenge is to write a Python function that asks the user for the current month and displays all the crops that can be planted in that month.

Example Input/Output:

Enter the current month: April
Crops you can plant in April:
- Carrot
- Tomato

Challenge 2: Crops to Harvest This Month

Reusing similar code to the code provided to solve challenge 1, write another function Python function that asks the user for the current month and displays all the crops that can be harvested in that month.

Challenge 3: Container-Friendly Crops

Some gardeners have limited space and need to grow crops in pots. Write a function that lists all crops that can be grown in containers.

Example Output:

Container-friendly crops:
- Carrot
- Tomato

Challenge 4: Best Crops for Your Garden

Modify your program to ask the user about their soil type and sunlight conditions and then recommend crops that match their garden environment.

Example Input/Output

Enter your soil type: Sandy
Enter your sunlight condition (Full sun/Partial shade): Full sun

Crops suitable for your garden:
- Carrot

Challenge 5: Interactive Crop Assistant

Enhance your program by allowing users to search for a specific crop and view detailed growing advice, including watering needs and best companion plants.

Example Input/Output

Enter a crop name: Carrot

Carrot (Vegetable)
- Planting season: March - July
- Harvest season: June - October
- Soil type: Light, sandy, well-drained
-- Watering needs: Moderate
- Container-friendly: Yes

Python Code

Here is the full python code for this first challenge. Your task will be to re-use similar code to complete the remaining challenges described in the 5 tabs above.

unlock-access

Solution...

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

Did you like this challenge?

Click on a star to rate it!

Average rating 5 / 5. Vote count: 4

No votes so far! Be the first to rate this post.

As you found this challenge interesting...

Follow us on social media!