Finding the average of a list
Here is a Python code snippet for finding the average of a list of numbers:
Tags
Here is a Python code snippet for finding the average of a list of numbers:
Finding the average of a list of numbers in Python
python— editable, runs on the server
Info
Watch a video course: Python - The Practical Guide
This code defines a list of numbers, then calculates the average by dividing the sum of the numbers in the list by the number of elements in the list. The sum() function adds up all the elements in a list and the len() function returns the number of elements in a list.