Python || Find The Average Using A List – Omit Highest And Lowest Scores

Print Friendly, PDF & Email

This page will consist of a program which calculates the average of a specific amount of numbers using a list.

REQUIRED KNOWLEDGE FOR THIS PROGRAM

Lists
For Loops
Arithmetic Operators
Basic Math - How To Find The Average

The following program is fairly simple, and was used to introduce the list concept. This program prompts the user to enter the total amount of numbers they wish to find the average for, then displays the answer to the screen. Using a sort, this program also has the ability to find the average of a list of numbers, omitting the highest and lowest valued items.


QUICK NOTES:
The highlighted lines are sections of interest to look out for.

The code is heavily commented, so no further insight is necessary. If you have any questions, feel free to leave a comment below.

The following is sample output.

How many items do you want to place into the list?: 5

Enter item #1: 7
Enter item #2: 7
Enter item #3: 4
Enter item #4: 8
Enter item #5: 7

The current items inside the list are:
Item #1: 7
Item #2: 7
Item #3: 4
Item #4: 8
Item #5: 7

The average of the 5 numbers is 6.60

The average adjusted score omitting the highest and lowest result is 7.00

Was this article helpful?
👍 YesNo

Leave a Reply