“Cómo encontrar Avrage Python” Código de respuesta

Python promedio de 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

Cómo encontrar 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

Cómo encontrar 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

Cómo encontrar 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

Respuestas similares a “Cómo encontrar Avrage Python”

Preguntas similares a “Cómo encontrar Avrage Python”

Más respuestas relacionadas con “Cómo encontrar Avrage Python” en Python

Explore las respuestas de código populares por idioma

Explorar otros lenguajes de código