Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

average value of list elements in python

# Example to find average of list
number_list = [45, 34, 10, 36, 12, 6, 80]
avg = sum(number_list)/len(number_list)
print("The average is ", round(avg,2))
Comment

find average of list python

list = [15, 18, 2, 36, 12, 78, 5, 6, 9]

# for older versions of python
average_method_one = sum(list) / len(list) 
# for python 2 convert len to a float to get float division
average_method_two = sum(list) / float(len(list))

# round answers using round() or ceil()
print(average_method_one)
print(average_method_two)
Comment

python get average of list


#python3

def average(list): 
    result = sum(list) / len(list) 
    return result 

list = [68,68,71,71,71,75,71,78,91,98,75,71,84]
print(average(list))
Comment

python find the average of a list

numbers = [3, 18, 2, 1, 70, 12, 36, 12, 78, 5, 6, 9]

import statistics

print(statistics.mean(numbers))
Comment

Python Program to Calculate the Average of Numbers in a Given List

n=int(input("Enter the number of elements to be inserted: "))
a=[]
for i in range(0,n):
    elem=int(input("Enter element: "))
    a.append(elem)
avg=sum(a)/n
print("Average of elements in the list",round(avg,2))
Comment

average of a list in function with python

def lol(a):
	x = sum(a)/len(a)
	print(x)
lol([5,7,3,9,4])
Comment

PREVIOUS NEXT
Code Example
Python :: pandas dataframe how to store 
Python :: pandas replace column values 
Python :: pairplot yaxis diagonal 
Python :: separating numeric and categorical feature using loop 
Python :: FizzBuzz in Python Using itertools 
Python :: zip list python first element 
Python :: pyttsx3 listen to events 
Python :: insertion sort algorithm in descending order 
Python :: Python Anagram Using sorted() function 
Python :: Find Factors of a Number Using Class 
Python :: Simple Python Permutation Printing result without for loop 
Python :: Code to find maximum number using if else 
Python :: enumerate zip together 
Python :: linear search algorithm python 
Python :: python get text that is already printed 
Python :: vortex identification 
Python :: CHECK POLYGON IS VALID 
Python :: apropos, help 
Python :: Python NumPy atleast_2d Function Syntax 
Python :: geopandas nc file 
Python :: Python NumPy asarray Function Example list to array 
Python :: Python NumPy column_stack Function Example with 1d array 
Python :: Python NumPy hsplit Function 
Python :: __div__ 
Python :: python service linux 
Python :: NumPy packbits Code Packed array along default axis 
Python :: how to separate data from two forms in django 
Python :: selenium send text in p html tag 
Python :: knn compute_distances_one_loop 
Python :: opencv2.3 
ADD CONTENT
Topic
Content
Source link
Name
7+1 =