41 lines
833 B
Python
41 lines
833 B
Python
def analyzer(input):
|
|
|
|
# empty array
|
|
split = []
|
|
|
|
# split string naar array
|
|
temp = input.split("-")
|
|
|
|
# converteer string naar int
|
|
for i in temp:
|
|
split.append(int(i))
|
|
|
|
# sorteer array
|
|
split.sort()
|
|
|
|
# grootste en kleinste getal
|
|
grootste = split[-1]
|
|
kleinste = split[0]
|
|
|
|
# aantal ints in array
|
|
aantal = len(split)
|
|
|
|
# som van array
|
|
som = sum(split)
|
|
|
|
# gemiddelde
|
|
gemiddelde = som/aantal
|
|
|
|
# alles omzetten naar tuple
|
|
ret = (split, grootste, kleinste, aantal, som, gemiddelde)
|
|
return ret
|
|
|
|
uitkomst = analyzer("5-9-7-1-7-8-3-2-4-8-7-9")
|
|
|
|
print("Gesorteerde lijst van ints: "+str(uitkomst[0]))
|
|
print("Grootste getal: " + str(uitkomst[1]) + " en Kleinste getal: " + str(uitkomst[2]))
|
|
print("Aantal getallen: " + str(uitkomst[3]) + " en Som van de getallen: " + str(uitkomst[4]))
|
|
print("Gemiddelde: " + str(uitkomst[5]))
|
|
|
|
|