Lập trình với AI dành cho Developer
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"""
[...]
Lời nhắc của người dùng: Tạo docstring cho hàm này bao gồm:
Phản hồi của mô hình:
Đây là docstring đầy đủ cho hàm của bạn:
def sales_trend(self):
"""
Analyze the sales data to determine whether there is an increasing trend
or a decreasing/stable trend over time.
[...]
"""
Đây là docstring đầy đủ cho hàm của bạn:
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.
[...]
"""



Dưới đây là bản nháp README.md đã chỉnh sửa cho lớp SalesAnalyzer:
SalesAnalyzer
Lớp SalesAnalyzer cung cấp cách đơn giản để phân tích dữ liệu doanh số theo ngày và phát hiện xu hướng doanh số đang tăng hay giảm/ổn định. Công cụ này hữu ích cho doanh nghiệp hoặc cá nhân muốn có cái nhìn tổng quan, nhanh về hiệu suất bán hàng theo thời gian.

(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)


Lập trình với AI dành cho Developer