|
''' Soren DeOrlow IDSN 599, Fall 2021 deorlow@usc.edu Lab practical 6 ''' santasList1 = [] def processFile(santasDocument): santasDocumentName = str santasDocument = int santasDocument = open("numbers.txt", "r") for line in santasDocument: line = line.strip() santasList1.append(line.strip()) santasDocument.close() santasDocument.name = santasDocumentName return (santasDocument) def getMax(santasBigNum): santasBigNum = max(santasList1) return (santasBigNum) def getMin(santasLilNum): santasLilNum = min(santasList1) return (santasLilNum) def getAvg(aveNum, sumNum): aveNum = len(santasList1) sumNum = sum(santasList1) avgValue = sumNum / aveNum return (avgValue) def main(): santasDocument = open("numbers.txt", "r") for line in santasDocument: line = line.strip() santasList1.append(line.strip()) santasDocument.close() for i in range(0, len(santasList1)): santasList1[i] = int(santasList1[i]) santasDocument = open("numbers.txt", "r") santasDocumentName = santasDocument.name santasBigNum = max(santasList1) santasLilNum = min(santasList1) aveNum = len(santasList1) sumNum = sum(santasList1) avgValue = sumNum / aveNum print("Santa's file:", santasDocumentName) print("Santa's big number:", getMax(santasBigNum)) print("Santa's little number:", getMin(santasLilNum)) print("Santa's average:", getAvg(aveNum, sumNum)) main()