Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

In Python: #Q1: Consider the sales data of each marketing agents for the last th

ID: 3908421 • Letter: I

Question

In Python:

#Q1: Consider the sales data of each marketing agents for the last three month.
# we want to find the average of sales for each agenet as well as min and max
#among all agent.
# 5 points
filename = 'data.txt'
# first open the data.txt and see the data.
try:
popfile = '?'(filename, 'r') # open the file
line = popfile.'?' # read the first line
dictA = '?' # create an empty dictionart
while line != '':
words = line.'?/ # split based on ,
dictA['?1'] = [float(words[i].'?2') for i in range(1,4)]
# In the above line, for '?1' provide the key.
# For '?2' remove extra whitspace and enters.
line = popfile.'?' # read the next first line
dictB = '?' # create an empty dictionart
for var1 in dictA.keys(): # find the average for each key of dictA.
dictB[var1] = round(sum(dictA.'?'(var1))/len(dictA.get(var1)),2)

maxvalue = '?' # this loops find the max average of sales.
for var1 in dictB.keys():
if dictB.get(var1) > maxvalue:
maxvalue = dictB.get(var1)

maxholder = [ ]
for var1 in dictB.keys(): # this loops find who has the max of average of sales.
if dictB.'?'(var1) == '?' :
maxholder.'?'(var1)
'?':
print('the file does not exist in th ecurrent directory')
pass

Explanation / Answer

#Q1: Consider the sales data of each marketing agents for the last three month. # we want to find the average of sales for each agenet as well as min and max #among all agent. # 5 points filename = 'data.txt' # first open the data.txt and see the data. try: popfile = open(filename, 'r') # open the file line = popfile.readline() # read the first line dictA = {} # create an empty dictionart while line != '': words = line.split(',') # split based on , dictA[words[0]] = [float(words[i].strip()) for i in range(1,4)] # In the above line, for '?1' provide the key. # For '?2' remove extra whitspace and enters. line = popfile.readline() # read the next first line dictB = {} # create an empty dictionart for var1 in dictA.keys(): # find the average for each key of dictA. dictB[var1] = round(sum(dictA.get(var1))/len(dictA.get(var1)), 2) maxvalue = 0 # this loops find the max average of sales. for var1 in dictB.keys(): if dictB.get(var1) > maxvalue: maxvalue = dictB.get(var1) maxholder = [ ] for var1 in dictB.keys(): # this loops find who has the max of average of sales. if dictB.get(var1) == maxvalue : maxholder.append(var1) except: print('the file does not exist in th ecurrent directory') pass

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote