What is the total and average of 4, 6, 8, 5, 7?

What is the total and average of 4, 6, 8, 5, 7?

Related Posts

This Post Has 4 Comments

  1. See explaination


    # Declare a named constant for array size here.


    # Declare array here.

    averages = []

    # Write a loop to get batting averages from user and assign to array.

    for i in range(MAX_AVERAGES):

    averageString = input("Enter a batting average: ")

    battingAverage = float(averageString)

    # Assign value to array.


    # Assign the first element in the array to be the minimum and the maximum.

    minAverage = averages[0]

    maxAverage = averages[0]

    # Start out your total with the value of the first element in the array.

    total = averages[0]

    # Write a loop here to access array values starting with averages[1]

    # Within the loop test for minimum and maximum batting averages.

    for i in range(1, MAX_AVERAGES):

    if averages[i] < minAverage:

    minAverage = averages[i]

    if averages[i] > maxAverage:

    maxAverage = averages[i]

    total += averages[i]

    # Also accumulate a total of all batting averages.

    # Calculate the average of the 8 batting averages.

    average = total / MAX_AVERAGES

    # Print the batting averages stored in the averages array.

    for avg in averages:


    # Print the maximum batting average, minimum batting average, and average batting average.

    print('Maximum batting average is ' + str(maxAverage))

    print('Minimum batting average is ' + str(minAverage))

    print('Average batting average is ' + str(average)

  2. Their total is 30.
    Since there are 5 of them, their average is 1/5 of their total = 6 .
    Their total is the same as it would be if every number were 6 . That's what 'average' and 'mean' mean.

Leave a Reply

Your email address will not be published. Required fields are marked *