Answers for "how to find average in python"

12

average value of list elements in python

# 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))
Posted by: Guest on February-14-2020
5

python average

def avrg(values): # where values is a list of all values
  return sum(values)/len(values)
Posted by: Guest on March-27-2021
1

make averages on python

# 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]))
Posted by: Guest on April-14-2020
1

how to use a function to find the average in python

avreage_cost = cost
    avg = sum(avreage)/len(avreage) 
    print("The average amout you spent is ", round(avg,2))
Posted by: Guest on March-20-2020
1

python average function program

#!/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()
Posted by: Guest on June-18-2020
0

average python

import numpy as np
values=[1,10,100]
print(np.mean(values))
values=[1,10,100,np.nan]
print(np.nanmean(values))
Posted by: Guest on March-21-2020

Code answers related to "how to find average in python"

Python Answers by Framework

Browse Popular Code Answers by Language