AI-Assisted Coding for Developers
Francesca Donadoni
AI Curriculum Manager, DataCamp

def sales_trend(self):
...
if increasing > decreasing:
return "Increasing trend"
else:
return "Decreasing or stable trend"
def sales_trend(self):
"""Analyze sales data to determine the overall trend"""
[...]
User prompt: Generate a docstring for this function that includes:
Model's response:
Here's a complete docstring you can use for your function:
def sales_trend(self):
"""
Analyze the sales data to determine whether there is an increasing trend
or a decreasing/stable trend over time.
[...]
"""
Here's a complete docstring you can use for your function:
def sales_trend(self):
"""
Analyze the sales data to determine whether there is an increasing trend
or a decreasing/stable trend over time.
Parameters
----------
self : object
An object that contains an attribute `daily_sales` (list of int or float),
which represents daily sales values in chronological order.
[...]
"""



Here's a polished README.md draft for your SalesAnalyzer class:
SalesAnalyzer
The SalesAnalyzer class provides a simple way to analyze daily sales data and detect whether the sales trend is generally increasing or decreasing/stable. This tool can be useful for businesses or individuals who want a quick, high-level overview of their sales performance over time.

(base) datacamp@test:~/datacamp/docstring-generation$ git diff
+
+ Raises:
+ ValueError: If daily_sales contains non-numeric values.
"""
- return sum(self.daily_sales)
+ if not all(isinstance(sale, (int, float)) for sale in self.daily_sales):
+ raise ValueError("All sales figures must be numeric.")
+ return sum(sale for sale in self.daily_sales)


AI-Assisted Coding for Developers