“Comment trouver Avrage Python” Réponses codées

Python moyen calcutalte

# 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]))
Envious Earthworm

Comment trouver Avrage Python

# Example to find avearge of list
from numpy import mean
number_list = [45, 34, 10, 36, 12, 6, 80]
avg = mean(number_list)
print("The average is ", round(avg,2))
The CODER man

Comment trouver Avrage 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))
The CODER man

python avg

my_list = [1,2,3,4]

import numpy as np
print("mean = ", np.mean(my_list))
Filthy Falcon

Comment trouver Avrage Python

Input : [4, 5, 1, 2, 9, 7, 10, 8]
Output : Average of the list = 5.75
Explanation:
Sum of the elements is 4+5+1+2+9+7+10+8 = 46
and total number of elements is 8.
So average is 46 / 8 = 5.75

Input : [15, 9, 55, 41, 35, 20, 62, 49]
Output : Average of the list = 35.75
Explanation:
Sum of the elements is 15+9+55+41+35+20+62+49 = 286
and total number of elements is 8.
So average is 46 / 8 = 35.75
The CODER man

Réponses similaires à “Comment trouver Avrage Python”

Questions similaires à “Comment trouver Avrage Python”

Plus de réponses similaires à “Comment trouver Avrage Python” dans Python

Parcourir les réponses de code populaires par langue

Parcourir d'autres langages de code