mean of values in list of string python code example
Example 1: python average
import statistics as st
my_list = [9, 3, 1, 5, 88, 22, 99]
print(st.mean(my_list))
Example 2: python average function program
import math
import os
import random
import re
import sys
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()