{"id":8616,"date":"2021-09-30T11:00:56","date_gmt":"2021-09-30T05:30:56","guid":{"rendered":"https:\/\/python-programs.com\/?p=8616"},"modified":"2021-11-22T18:35:30","modified_gmt":"2021-11-22T13:05:30","slug":"python-program-to-calculate-the-average-of-numbers-in-a-given-list","status":"publish","type":"post","link":"https:\/\/python-programs.com\/python-program-to-calculate-the-average-of-numbers-in-a-given-list\/","title":{"rendered":"Python Program to Calculate the Average of Numbers in a Given List"},"content":{"rendered":"

Don’t miss the chance of Java programs examples with output pdf free download<\/a> as it is very essential for all beginners to experienced programmers for cracking the interviews.<\/p>\n

List in Python :<\/strong><\/p>\n

The list data type is one of the most often used data types in Python. The square brackets [ ] easily identify a Python List. Lists are used to store data items, with each item separated by a comma (,). A Python List can include data elements of any data type, including integers and Booleans.<\/p>\n

One of the primary reasons that lists are so popular is that they are mutable. Any data item in a List can be replaced by any other data item if it is mutable. This distinguishes Lists from Tuples, which are likewise used to store data elements but are immutable.<\/p>\n

Given a list, the task is to Calculate the average of all the numbers in the given list in python.<\/p>\n

Examples:<\/strong><\/p>\n

Example1:<\/strong><\/p>\n

Input:<\/strong><\/p>\n

given list = [8, 9, 1, 23, 15, 20, 19, 13, 8, 7, 5, 2, 7, 10, 14, 16]<\/pre>\n

Output:<\/strong><\/p>\n

The average value of the given list [8, 9, 1, 23, 15, 20, 19, 13, 8, 7, 5, 2, 7, 10, 14, 16] = 11.0625<\/pre>\n

Example2:<\/strong><\/p>\n

Input:<\/strong><\/p>\n

given list = [  47 24.5 27 28 11 23 34.8 33 31 29 45 37 39 ]<\/pre>\n

Output:<\/strong><\/p>\n

The average value of the given list [47.0, 24.5, 27.0, 28.0, 11.0, 23.0, 34.8, 933.0, 31.0, 29.0, 45.0, 37.0, 39.0] = 100.71538461538461<\/pre>\n

Program to Calculate the Average of Numbers in a Given List in Python<\/h2>\n

There are several ways to calculate the average of all numbers in the given list in Python some of them are:<\/p>\n