The Digital Botanist
Welcome to the greenhouse! Your mission is to create a "smart" assistant that can give perfect watering advice for different types of plants. You'll write a function that acts as the brain of this assistant.
The Rules of Botany (and Function Logic):
The Safety Rule - If the soil is already damp (
is_soil_dampisTrue), you should never water the plant, regardless of any other condition.Succulents (
"Succulent") - These desert plants are sensitive to overwatering. Do not water them if they have been watered in the last 12 days.Tropicals (
"Tropical") - These plants love moisture. Water them if it has been more than 3 days since their last watering.All Other Plants (
"Default") - For any other plant type, follow a general rule: water them if it has been more than 7 days since their last watering.Error Handling - if
plant_typeis not one of the types you handle, return respective message.Borderline Cases - If it's the last day of a period, recommend to check at the next day.
Based on a set of rules, the function must return a string with the correct advice: "Do not water", "Water the plant", "Unknown plant type" or "Check the soil again tomorrow".
Input: Three arguments: plant_type as string (str), days_since_watering as integer (int) and is_soil_damp as logic value (bool).
Output: String.
Examples:
assert get_watering_advice("Succulent", 11, True) == "Do not water"
assert get_watering_advice("Tropical", 3, False) == "Check the soil again tomorrow"
assert get_watering_advice("Default", 8, False) == "Water the plant"
assert get_watering_advice("Plant", 8, False) == "Unknown plant type"