Sublle Em...Emplvasis Intense E Strong Quote Styles 1: Consider the sales data o
ID: 3908932 • Letter: S
Question
Sublle Em...Emplvasis Intense E Strong Quote Styles 1: Consider the sales data of each marketing agents for the last three month. , ?? ????to find the average of sales for each aaenet as ven as sin and nex #among all agent. t s points tilcnanC 'data.txt t first open the data.txt and see the data. . pentas- '?'(tusnaas. iae popfile.'? .r.) t open the file # read the first line # create an empty actionare while line sards-line.'?/ #split based& astAL' ?1']-[float (words [1]..72.) for incanasu,4)] # In the above line, for '21. provide the key. # For '22. remove extra whiEpace and enters. t read the next first iine # create an empty dictionare tax varl in dictA.kexa): # find the average for each key of assa, dictBlvarll round (sum (dictA. '' (var1)) /lenidictA.get (varl)),2) maxvalue '?' r varl in dictB.keys0: # ? loops find the max average of sales. if dictB.get (vari) >maxvalu: maxvalue dictB.get (vari) £2?vari in dicte.keve(); # this loops find who has the max of average of sales. maxholdex.'2"(vari) RE?ALI 'the file does not exist in ecurrent directory.)Explanation / Answer
here is your answer : ---------->>>>>>>>>
filename = 'data.txt'
try:
popfile = open(filename,'r')
line = popfile.readLine()
dictA = dict()
while line != "":#here you can check for empty string for end of file
words = line.split(',')
dictA[words[0]] = [float(words[i].strip()) for i in range(1,4)]
line = popfile.readLine()
dictB = dict()
for var1 in dictA.keys():
dictB[var1] = round(sum(dictA.get(var1))/len(dictA.get(var1)),2)
maxvalue = dictB.get(0)
for var1 in dictB.keys():
if dictB.get(var1) > maxvalue:
maxvalue = dictB.get(var1)
maxholder = []
for var1 in dictB.keys():
if dictB.get(var1) == maxvalue:
maxholder.append(var1)
except:
print('the file does not exist in the current directory')
pass
#question 2 : --------->>>>>>>>>
class Player():
def __init__(self,name,age):
self.name = name
self.age = age
def ShowInfo(self):
print(self.name + ' is ' + str(self.age) + ' old ')
class Defender(Player):
def __init__(self,name,age):
super.__init__(name,age)
self.income = 10000
def ShowInfo(self):
print(self.name + ' is ' + str(self.age) + ' old ' + 'with ' + str(self.income) + ' income ')
player1 = Player('John',25)
player1.ShowInfo()
player2 = Defender('Joe',27)
player2.ShowInfo()
#Question 3 : ----------->>>>>>>>
import random
import pygal
data = []
for i in range(10001):
x = random.randint(1,10)
data.append(x)
frequencis = []
for i in set(data):
frequency = data.count(i)