Sunday, 5 March 2023

Predict inventory stock end date using Python

Here's an example Python code that predicts the end date of inventory stock based on the current stock level and average daily sales:


from datetime import date, timedelta


# Current stock level

current_stock = 1000


# Average daily sales

avg_daily_sales = 50


# Calculate days until stock runs out

days_until_empty = current_stock / avg_daily_sales


# Calculate end date of inventory stock

end_date = date.today() + timedelta(days=days_until_empty)


# Print end date in YYYY-MM-DD format

print(end_date.strftime('%Y-%m-%d'))

In this example, we assume that the current stock level is 1000 and the average daily sales are 50. We calculate the number of days until the stock runs out by dividing the current stock by the average daily sales. We then add this number of days to today's date to get the end date of the inventory stock. Finally, we print the end date in the YYYY-MM-DD format.

No comments:

Post a Comment