CBSE Class 12 Computer Science
Question 68 of 120
Review of Python Basics — Question 20
Back to all questions 20
Question Write a program to calculate the mean of a given list of numbers.
numbers = eval(input("Enter a list: "))
if len(numbers) == 0:
print("List is empty, cannot calculate mean.")
else:
total = sum(numbers)
n = len(numbers)
mean = total / n
print("Mean of the numbers:", mean)Enter a list: [10, 30, 25, 34, 45, 98]
Mean of the numbers: 40.333333333333336