Input 10 numbers and find average of positive numbers using while loop in Python
while Loop - Question 4
In this question, we will see how to input 10 numbers and find the average of only positive numbers in Python programming using while loop. To know more about while loop click on the while loop lesson.
Q4) Write a program in Python to input 10 numbers and find the average of only positive numbers using while loop.
i=1; sum=0; c=0 print('Enter 10 numbers') while i<=10: n=int(input()) if n>0: sum=sum+n c=c+1 avg=sum/c i=i+1 print('Average of positive numbers = %d' %(avg))
Enter 10 numbers -12 -6 12 -4 20 3 -89 -51 -7 5 Average of positive numbers = 10