How to use 'list average python' in Python

Every line of 'list average python' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your Python code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
this disclaimer
104def test_averageOnList(self):
105 items = [0, 8, 4, 10]
106 res = BlocklyMethods.averageOnList(items)
107 self.assertEqual(5.5, res)
Important

Use secure code every time

Secure your code as it's written. Use Snyk Code to scan source code in minutes – no build needed – and fix issues immediately. Enable Snyk Code

59def average(average_window, data):
60 window = []
61 newdata = []
62 for v in data:
63 window.append(v)
64 if len(window) == average_window:
65 newdata.append(sum(window)/average_window)
66 del window[0]
67 return newdata

Related snippets