Answered step by step
Verified Expert Solution
Question
1 Approved Answer
FIX MY CODE! NOT LINED UP CORRECTLY _ THANK YOU IN ADVANCE # Function to initialize a 2 D array with zeros def initialize _
FIX MY CODE! NOT LINED UP CORRECTLY THANK YOU IN ADVANCE
# Function to initialize a D array with zeros
def initializedarrayrows cols:
return cols for in rangerows
# Function to read and process the sales data
def processsalesdatafilepath:
# Initialize sales data arrays
saleslocations Houston "Dallas Fortworth", "Austin", "San Antonio", "Corpus Christi"
automodels A allroad", A Coupe", S Coupe", RS Q Sedan", Q Sportback",
SQ etron", etron GTS Sedan", FF Heritage"
unitprices
# Initialize D array for sales
salesarray initializedarraylensaleslocations lenautomodels
# Read and process the sales data from the file
with openfilepath, r as file:
for line in file:
# Extract location and model codes
locationcode intline:
modelcode intline:
# Update the sales array
salesarraylocationcodemodelcode
# Display the report
printreportsalesarray, saleslocations, automodels, unitprices
# Function to print the sales report
def printreportsalesarray, saleslocations, automodels, unitprices:
# Print the report header
print
print Europian Auto Traders"
print Sales By Location"
printf Report Date: ::
print Name: Stephen Washington"
print
# Print the Auto Models header
print Auto Models"
printLocation Name end
for model in automodels:
printfmodel: end
print
# Print the sales data
for i location in enumeratesaleslocations:
printflocation: end
for j model in enumerateautomodels:
printfsalesarrayij: end
print
# Print the separator
print lenautomodels
# Print the Totals header
print end
for j in rangelenautomodels:
printfsumrowj for row in salesarray: end
print
# Print the Unit Price header
printUnit Price end
for price in unitprices:
printfprice:f end
print
# Print the separator
print lenautomodels
# Print the Totals Earned header
printTotals Earned", end
for j in rangelenautomodels:
totalearned sumsalesarrayij unitpricesj for i in rangelensaleslocations
printftotalearned:f end
print
# Print the final separator
print lenautomodels
# Call the function with the file path
processsalesdataautoSalesdat"
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started