Week 21 - Calculating average, min and max

posted May 5, 2017, 7:56 AM by Attila Lengyel
iCount = int(input("How many numbers?:"))
iSum = 0
iMin = 0
iMax = 0
lNumbers = []
for x in range(0, iCount):
  iNum = int(input("Give me a number:"))
  lNumbers.append(iNum)
  if x == 0:
    iMin = iNum
    iMax = iNum
  else:
    if iNum < iMin: iMin = iNum
    if iNum > iMax: iMax = iNum
  iSum += iNum
lNumbers.sort()
print(lNumbers)
print("The average is", iSum/iCount)
print("The minimum: ", iMin)
print("The maximum: ", iMax)




Comments