WAP to calculate the mean of a given list of numbers with full python programming ok
Answers
Answered by
2
Explanation:
- Take the number of elements to be stored in the list as input.
- Use a for loop to input elements into the list.
- Calculate the total sum of elements in the list.
- Divide the sum by total number of elements in the list.
- Exit.
Answered by
22
data = eval(input("Enter the numbers: "))
s = 0
for i in data:
s = s + i
mean = s/len(data)
print(mean, "is the mean.")
- eval() enables the data that is entered to be used in its integer form, or string form, depending upon the succeeding codes.
- Using a for loop, enables i to take every value that is input, and carry on with the next operation.
- len() is a function that calculates the number of characters.
Attachments:
Similar questions
Social Sciences,
4 months ago
English,
4 months ago
English,
1 year ago
Math,
1 year ago
Math,
1 year ago