Python Program to Find List Items Greater Than Average

Write a Python program to find list items greater than average. This python example allows us to enter list items then we will find the average of list items. Next, the for loop will iterate the list items, and the if condition checks each item against the list average. Finally, if it is greater than the average, print that list item.

```listAvg = []
Number = int(input("Total Number of List Items = "))

for i in range(1, Number + 1):
value = int(input("Enter the %d List Item = "  %i))
listAvg.append(value)

total = sum(listAvg)
avg = total / Number

print('\nList Sum = {0} and Average = {1}'.format(total, avg))

print('Total List Items Greater than the List Average')
for i in range(len(listAvg)):
if listAvg[i] > avg:
print(listAvg[i], end = ' ')```

This Python example finds the list items greater than the average using a for loop.

```listAvg = []
Number = int(input("Total Number of List Items = "))

total = 0
for i in range(Number):
value = int(input("Enter the %d List Item = "  %(i+1)))
listAvg.append(value)
total = total + listAvg[i]

avg = total / Number

print('\nList Sum = {0} and Average = {1}'.format(total, avg))

print('Total List Items Greater than the List Average')
for i in range(len(listAvg)):
if listAvg[i] > avg:
print(listAvg[i], end = ' ')```
``````Total Number of List Items = 7
Enter the 1 List Item = 22
Enter the 2 List Item = 9
Enter the 3 List Item = 11
Enter the 4 List Item = 18
Enter the 5 List Item = 29
Enter the 6 List Item = 139
Enter the 7 List Item = 44

List Sum = 272 and Average = 38.857142857142854
Total List Items Greater than the List Average
139 44 ``````

Python program to find list items greater than average using a while loop.

```listAvg = []
Number = int(input("Total Number of List Items = "))

total = 0
i = 1
while(i <= Number):
value = int(input("Enter the %d List Item = "  %(i+1)))
listAvg.append(value)
i = i + 1

i = 0
while(i < Number):
total = total + listAvg[i]
i = i + 1

avg = total / Number

print('\nList Sum = {0} and Average = {1}'.format(total, avg))

print('Total List Items Greater than the List Average')
for i in range(len(listAvg)):
if listAvg[i] > avg:
print(listAvg[i], end = ' ')```
``````Total Number of List Items = 9
Enter the 2 List Item = 4
Enter the 3 List Item = 11
Enter the 4 List Item = 3
Enter the 5 List Item = 2
Enter the 6 List Item = 9
Enter the 7 List Item = 22
Enter the 8 List Item = 7
Enter the 9 List Item = 15
Enter the 10 List Item = 17

List Sum = 90 and Average = 10.0
Total List Items Greater than the List Average
11 22 15 17 ``````