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 Average(nums):
2 return sum(nums) / len(nums)
3
4lis = []
5
6for x in range(100000):
7 nums =int(input("enter numbers: "))
8 command = input()
9 lis.append(nums)
10 if command == "e":
11 break
12
13
14
15output = Average(lis)
16
17print("the average is ",output)
18
19
1def avrg(values): # where values is a list of all values
2 return sum(values)/len(values)
1 avreage_cost = cost
2 avg = sum(avreage)/len(avreage)
3 print("The average amout you spent is ", round(avg,2))
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))