Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

mean of a list python

import numpy as np
np.mean(list)
np.std(list)
Comment

list mean python

# Python program to get average of a list

def Average(lst): 
	return sum(lst) / len(lst) 

# Driver Code 
lst = [15, 9, 55, 41, 35, 20, 62, 49] 
average = Average(lst) 

# Printing average of the list 
print("Average of the list =", round(average, 2)) 

# Output:
# Average of the list = 35.75
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 average of list

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

import statistics

print(statistics.mean(numbers))
Comment

mean of a list python

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

# By using the built-in statistics library
import statistics
statistics.mean(l)  # 20.11111111111111

# By defining a custom function
def average(my_list):
  return sum(my_list) / len(my_list)
average(l) # 20.11111111111111
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 :: skip header in csv python 
Python :: which python mac 
Python :: python pandas change column values to all caps 
Python :: check empty dataframe 
Python :: python has duplicates 
Python :: pad zeros to a string python 
Python :: closing text files in python 
Python :: message box for python 
Python :: python get num classes from label encoder 
Python :: hoe maak je machten in python 
Python :: how to provide default value when assign i ngvariables python 
Python :: if(guess_password == list(password): 
Python :: get current file location 
Python :: check if directory exists python 
Python :: pandas show complete string 
Python :: change name of column pandas 
Python :: how to make a bot say hello <username when a user says hello in discord with python 
Python :: python make a shop menu 
Python :: print('Test set predictions: {}'.format(y_pred)) 
Python :: pandas print duplicate rows 
Python :: python calling dynamic function on object 
Python :: python nested tqdm 
Python :: create dataframe with column names pandas 
Python :: replace the jinja template value inside the dictionary python 
Python :: python dir all files 
Python :: The authorization mechanism you have provided is not supported. Please use AWS4-HMAC-SHA256 
Python :: how to create text file with python and store a dictionary 
Python :: pandas print dataframe dtypes 
Python :: programe to check if a is divisible 
Python :: datetime to string python 
ADD CONTENT
Topic
Content
Source link
Name
2+5 =