List average

    0

    0

    Mahendra Kumar

    beginnerListbasicMaths•••

    Python program to calculate the average of numbers in a given list

    def find_Average(n):
        sum_num = 0
        for i in n:
            # calculate sum of numbers in list
            sum_num = sum_num + i        
        # calculate average of numbers in list
        avg = sum_num / len(n)
        return avg
    # take list
    l = [5, 3, 8, 20, 15]
    # calling function and display result
    print('The average of list = %0.2f' %find_Average(l))
    
    Codiga Logo
    Codiga Hub
    • Rulesets
    • Playground
    • Snippets
    • Cookbooks
    soc-2 icon

    We are SOC-2 Compliance Certified

    G2 high performer medal

    Codiga – All rights reserved 2022.