1# Example to find average of list
2number_list = [45, 34, 10, 36, 12, 6, 80]
3avg = sum(number_list)/len(number_list)
4print("The average is ", round(avg,2))
5
1def avrg(values): # where values is a list of all values
2 return sum(values)/len(values)
1# app.py
2
3def averageOfList(num):
4 sumOfNumbers = 0
5 for t in num:
6 sumOfNumbers = sumOfNumbers + t
7
8 avg = sumOfNumbers / len(num)
9 return avg
10
11
12print("The average of List is", averageOfList([19, 21, 46, 11, 18]))
1#!/bin/python3
2
3import math
4import os
5import random
6import re
7import sys
8
9
10# write your code here
11def avg(*n):
12 sumOfNumber = 0
13 for t in n:
14 sumOfNumber = sumOfNumber + t
15 avge = sumOfNumber / len(n)
16 return avge
17if __name__ == '__main__':
18 fptr = open(os.environ['OUTPUT_PATH'], 'w')
19
20 nums = list(map(int, input().split()))
21 res = avg(*nums)
22
23 fptr.write('%.2f' % res + '\n')
24
25 fptr.close()
1import numpy as np
2values=[1,10,100]
3print(np.mean(values))
4values=[1,10,100,np.nan]
5print(np.nanmean(values))