0
Q:

python mean

if a == 2: # Compares whether a is equal to 2
    print a
1
import statistics

a = [1,2,3,4,5]

mean = statistics.mean(a) 
#Similar for other values such as variance, standard deviation
0
import numpy as np
values=[1,10,100]
print(np.mean(values))
values=[1,10,100,np.nan]
print(np.nanmean(values))
1
# Probably the most convenient set of statistics functions are found
# in the Numpy package

# Basic syntax:
import numpy as np
np.mean(your_list) # Calculate mean
np.median()	# Calculate median
np.std()	# Calculate standard deviation
np.var()	# Calculate variance
1
#!/bin/python3

import math
import os
import random
import re
import sys


# write your code here
def avg(*n):
    sumOfNumber = 0
    for t in n:
        sumOfNumber = sumOfNumber + t
    avge = sumOfNumber / len(n)
    return avge
if __name__ == '__main__':
    fptr = open(os.environ['OUTPUT_PATH'], 'w')
    
    nums = list(map(int, input().split()))
    res = avg(*nums)
    
    fptr.write('%.2f' % res + '\n')

    fptr.close()
1
# in python == means that is a comparisson operator meaning it compares if one 
# variable equals the other. Instead of using one = since that will assign
# a value we use ==
0

New to Communities?

Join the community