Average of numbers #7981
Replies: 3 comments 2 replies
-
Use this https://github.com/TheAlgorithms/Python/blob/master/maths/average_mean.py for a small amount of numbers (<100000). For higher amount of numbers you may have to use cumulative running mean and use the last value. |
Beta Was this translation helpful? Give feedback.
-
ADD the numbers and divide by 2 |
Beta Was this translation helpful? Give feedback.
-
To find the average of any amount of numbers, you can use the following Python code: def calculate_average(numbers): This code defines a function called calculate_average that takes a list of numbers as input. It initializes two variables, total and count, to 0. Then, it iterates over each number in the list and adds it to the total variable while incrementing the count variable. Finally, it returns the average by dividing the total by the count. To use this function, you can pass a list of numbers as an argument: numbers = [2, 4, 6, 8, 10] In this example, the list [2, 4, 6, 8, 10] is passed to the calculate_average function, and it returns the average, which is 6.0. |
Beta Was this translation helpful? Give feedback.
-
What is the code used to find the average/mean of any amount of numbers?
Beta Was this translation helpful? Give feedback.
All reactions