total = 0
count = 0
while True :
hey = input('Enter your mark: ')
if hey == 'done' : break
value = float(hey)
total = total + value
count = count + 1
average = total / count
print('Average: ', average)
prints, (gets the mark and gets the average of the last num until type done)
Enter your mark: 34 Enter your mark: 67 Enter your mark: 80 Enter your mark: done Average: 80.0
,,,,,The same using lists
num = list()
while True :
inp = input('Enter the mark: ')
if inp == 'done' : break
value = float(inp)
num.append(value)
average = sum(num) / len(num)
print('Average: ', average)
Enter the mark: 67 Enter the mark: 78 Enter the mark: 90 Enter the mark: 56 Enter the mark: done Average: 72.75