starter99
0
Q:

python average

import numpy as np
values=[1,10,100]
print(np.mean(values))
values=[1,10,100,np.nan]
print(np.nanmean(values))
1
# 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))
5
# Using statistics package to find average
import statistics as st

my_list = [9, 3, 1, 5, 88, 22, 99]
print(st.mean(my_list))
3
#!/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
# app.py

def averageOfList(num):
    sumOfNumbers = 0
    for t in num:
        sumOfNumbers = sumOfNumbers + t

    avg = sumOfNumbers / len(num)
    return avg


print("The average of List is", averageOfList([19, 21, 46, 11, 18]))
0
import numpy

 avreage_1 = numpy.mean(avreage)# this finds the mean from the array "cost"
    print("words are printed here if needed",avreage_1) # this prints the mean that was found above
    
    
0

New to Communities?

Join the community