- 15th Jul 2024
- 17:35 pm
In this assignment our experts can help enhance the profit/loss calculator by integrating the requested additional functionality, ensuring secure coding practices, and developing maintainable, readable code. They will also design the solution to identify trends in product sales and profits, providing a user-friendly interface with meaningful outputs.
Activity
- The file Task_4a_data.csv contains the data that will be used by the solution.
- The file Task4a_profit_loss.py contains the code that the senior developer has produced.
- Develop the programming code for the data service so that it meets the new system and user requirements provided in the Set Task Information.
During development of the solution make sure that you:
- consider the security requirements and use secure coding principles and practices to mitigate against potential threats and vulnerabilities
- ensure that your code is maintainable, readable and functional
- follow accepted programming conventions
Questions – outcomes for submission
- I need you to explain how the spreadsheet (task4a.data) as attached should meet the set task information.
- Your explanation should be exactly or in-line with the marking grade as attached.
- A working version of your solution as a .py file. (Outlining the information shown in the marking grade)
Enhancing the Profit/Loss Calculator for KRJ Retail Ltd - Get Python Assignment Solution
Please note that this is a sample assignment solved by our Python Experts. These solutions are intended to be used for research and reference purposes only. If you can learn any concepts by going through the reports and code, then our Python Tutors would be very happy.
- To download the complete solution along with Code, Report and screenshots - Please visit our Python Assignment Sample Solution page
- Reach out to our Python Tutors to get online tutoring related to this assignment and get your doubts cleared
- You can check the partial solution for this assignment in this blog below
Free Assignment Solution - Enhancing the Profit/Loss Calculator for KRJ Retail Ltd
import pandas as pd
import datetime
import matplotlib.pyplot as plt
import numpy as np
def profit_loss_menu():
flag = True
while flag:
print("###############################################")
print("Welcome! Please choose an option from the list")
print("1. Show profit/loss for specific products")
print("2. Show profit/loss for all products")
print("3. Show supplier profit specific products")
print("4. Show supplier profit for all products")
print("5. Show supplier quantity specific products")
print("6. Show supplier quantity for all products")
print("###############################################")
profit_loss_choice = input("Please enter the number of your choice (1-6): ")
try:
int(profit_loss_choice)
except:
print("Sorry, you did not enter a valid choice")
flag = True
else:
if int(profit_loss_choice) < 1 or int(profit_loss_choice) > 6:
print("Sorry, you did not neter a valid choice")
flag = True
else:
return int(profit_loss_choice)
def get_product_choice():
flag = True
while flag:
print("######################################################")
print("Please choose a product form the list:")
print("Please enter the number of the product (1-16)")
print("1. Potatoes")
print("2. Carrots")
print("3. Peas")
print("4. Lettuce")
print("5. Onions")
print("6. Apples")
print("7. Oranges")
print("8. Pears")
print("9. Lemons")
print("10. Limes")
print("11. Melons")
print("12. Cabbages")
print("13. Asparagus")
print("14. Broccoli")
print("15. Cauliflower")
print("16. Celery")
print("######################################################")
product_list = ["Potatoes", "Carrots", "Peas", "Lettuce", "Onions",
"Apples", "Oranges", "Pears", "Lemons", "Limes","Melons", "Cabbages",
"Asparagus", "Broccoli", "Cauliflower", "Celery"]
product_choice = input("Please enter the number of your choice (1-16): ")
try:
int(product_choice)
except:
print("Sorry, you did not enter a valid choice")
flag = True
else:
if int(product_choice) < 1 or int(product_choice) > 16:
print("Sorry, you did not neter a valid choice")
flag = True
else:
product_name = product_list[int(product_choice)-1]
return product_name
def get_supplier_choice():
flag = Tru
return pd.to_datetime(end_date, dayfirst=True)
def get_date_range_all():
df1 = pd.read_csv("products_list.csv")
df1["Date"] = pd.to_datetime(df1["Date"], dayfirst=True)
results = df1.loc[(df1["Date"] >= start_date) & (df1["Date"] <= end_date), df1.columns != "Supplier"].copy()
results["Cost Subtotal"] = results["KGs Purchased"] * results["Purchase Price"]
results["Sales subtotal"] = results["KGs Sold"] * results["Selling Price"]
results["Profit subtotal"] = results["Sales subtotal"] - results["Cost Subtotal"]
list_profits=results["Profit subtotal"].tolist();
list_dates=results["Date"].tolist();
plt.plot(list_profits, label = "sigmoid value", linestyle="-.")
plt.legend()
plt.xlabel("Date")
plt.ylabel("Profit_Subtotal")
plt.show(
total = round(results["Profit subtotal"].sum(),2)
results_print = results.to_string(index=False)
print(results)
print("The overall profit/loss for the selected time frame was £{}".format(total))
def get_supplier_profit():
df1 = pd.read_csv("products_list.csv")
#df2 = df.groupby('Supplier')['Fee'].sum()
#print(df2)
df1["Date"] = pd.to_datetime(df1["Date"], dayfirst=True)
results = df1.loc[(df1["Date"] >= start_date) & (df1["Date"] <= end_date)].copy()
results["Cost Subtotal"] = results["KGs Purchased"] * results["Purchase Price"]
results["Sales subtotal"] = results["KGs Sold"] * results["Selling Price"]
results["Profit subtotal"] = results["Sales subtotal"] - results["Cost Subtotal"
df2 = results.groupby('Supplier',as_index =False)['Profit subtotal'].sum()
list_profits=df2["Profit subtotal"].values.tolist();
list_suppliers=df2["Supplier"].values.tolist();
plt.bar(list_suppliers,list_profits)
#plt.plot(list_profits,list_suppliers, label = "sigmoid value", linestyle="-.")
plt.legend()
plt.xlabel("Suppliers")
plt.ylabel("Profit_Subtotal")
plt.show()
print(df2
def get_supplier_quantity():
df1 = pd.read_csv("products_list.csv")
#df2 = df.groupby('Supplier')['Fee'].sum()
#print(df2
df1["Date"] = pd.to_datetime(df1["Date"], dayfirst=True)
results = df1.loc[(df1["Date"] >= start_date) & (df1["Date"] <= end_date)].copy(
df2 = results.groupby('Supplier',as_index =False)['KGs Sold'].sum()
list_profits=df2["KGs Sold"].values.tolist();
list_suppliers=df2["Supplier"].values.tolist();
plt.bar(list_suppliers,list_profits)
#plt.plot(list_profits,list_suppliers, label = "sigmoid value", linestyle="-.")
plt.legend()
plt.xlabel("Suppliers")
plt.ylabel("KGs Sold")
plt.show()
print(df2)
def get_date_range_product():
product_name = get_product_choice()
df2 = pd.read_csv("products_list.csv")
df2["Date"] = pd.to_datetime(df2["Date"], dayfirst=True)
product_results = df2.loc[(df2["Date"] >= start_date) & (df2["Date"] <= end_date) & (df2["Product"] == product_name)].copy()
product_results["Cost Subtotal"] = product_results["KGs Purchased"] * product_results["Purchase Price"]
product_results["Sales subtotal"] = product_results["KGs Sold"] * product_results["Selling Price"]
product_results["Profit subtotal"] = product_results["Sales subtotal"] - product_results["Cost Subtotal"]
total = round(product_results["Profit subtotal"].sum(),2)
results_print = product_results.to_string(index=False)
print(product_results["Profit subtotal"])
print("The profit/loss for the {} for selected time frame was £{}".format(product_name, total))
def get_supplier_quantity_specefic():
supplier_name = get_supplier_choice()
df2 = pd.read_csv("products_list.csv")
df2["Date"] = pd.to_datetime(df2["Date"], dayfirst=True)
supplier_results = df2.loc[(df2["Date"] >= start_date) & (df2["Date"] <= end_date) & (df2["Supplier"] == supplier_name)].copy(
total = round(supplier_results["KGs Sold"].sum(),2)
results_print = supplier_results.to_string(index=False)
print(results_print)
print("The sold quantity for the {} for selected time frame was £{}".format(supplier_name, total))
def get_supplier_profit_specefic():
supplier_name = get_supplier_choice()
df2 = pd.read_csv("products_list.csv")
df2["Date"] = pd.to_datetime(df2["Date"], dayfirst=True)
supplier_results = df2.loc[(df2["Date"] >= start_date) & (df2["Date"] <= end_date) & (df2["Supplier"] == supplier_name)].copy()
supplier_results["Cost Subtotal"] = supplier_results["KGs Purchased"] * supplier_results["Purchase Price"]
supplier_results["Sales subtotal"] = supplier_results["KGs Sold"] * supplier_results["Selling Price"]
supplier_results["Profit subtotal"] = supplier_results["Sales subtotal"] - supplier_results["Cost Subtotal"]
total = round(supplier_results["Profit subtotal"].sum(),2)
results_print = supplier_results.to_string(index=False)
print(supplier_results["Profit subtotal"])
print("The profit/loss for the {} for selected time frame was £{}".format(supplier_name, total))
def process_menu_choice():
if profit_choice == 1:
get_date_range_product()
elif profit_choice==2:
get_date_range_all()
elif profit_choice==3:
get_supplier_profit_specefic()
elif profit_choice==4:
get_supplier_profit()
elif profit_choice==5:
get_supplier_quantity_specefic()
elif profit_choice==6:
get_supplier_quantity()
start_date = get_start_date()
end_date = get_end_date()
profit_choice = profit_loss_menu()
process_menu_choice()
import pandas as pd
try_df = pd.read_csv("products_list.csv")
print(try_df.dtypes)
Get the best Enhancing the Profit/Loss Calculator for KRJ Retail Ltd assignment help and tutoring services from our experts now!
About The Author - John Smith
John Smith is a skilled software developer with a strong background in retail solutions. He specializes in creating data-driven applications that meet specific business requirements. With experience in secure coding and system development, John excels in building maintainable, readable, and functional code. His work with KRJ Retail Ltd showcases his ability to integrate new functionalities, analyze trends, and deliver user-friendly interfaces.