Python Basics: How to Calculate the Average
This simple Python program allows the user to enter infinite values (with y/n conditions), then adds these entered numbers and displays the average.
Python code:-
a=[ ]
b='y'
while b=='y':
n=input('Enter a Number: ')
a.append(int(n))
b=input('Continue(y/n): ')
s=0
for number in a:
s += number
avg=s/len(a)
print(a)
print("The Sum is %d" % (s))
print("And Average is %f" % (avg))