Computer Science
Write a short program to find average of list of numbers entered through keyboard.
Python
Python Control Flow
32 Likes
Answer
sum = count = 0
print("Enter numbers")
print("(Enter 'q' to see the average)")
while True :
n = input()
if n == 'q' or n == 'Q' :
break
else :
sum += int(n)
count += 1
avg = sum / count
print("Average = ", avg)
Output
Enter numbers
(Enter 'q' to see the average)
2
5
7
15
12
q
Average = 8.2
Answered By
9 Likes
Related Questions
Write a program to take an integer a as an input and check whether it ends with 4 or 8. If it ends with 4, print "ends with 4", if it ends with 8, print "ends with 8", otherwise print "ends with neither".
Write a short program to print first n odd numbers in descending order.
Write a short program to print the following series :
(i) 1 4 7 10 ………. 40.
(ii) 1 -4 7 -10 ………. -40Write a program to input 3 sides of a triangle and print whether it is an equilateral, scalene or isosceles triangle.