Skip to content

Latest commit

 

History

History
45 lines (25 loc) · 635 Bytes

Calculate_average.md

File metadata and controls

45 lines (25 loc) · 635 Bytes

CodeWars Python Solutions


Calculate average

Write function avg which calculates average of numbers in given list.

Python:

  • Due to rounding issues please do not use statistics.mean or such.
  • If the array is empty, return 0.

Examples

number([]) # => []
number(["a", "b", "c"]) # => ["1: a", "2: b", "3: c"]

Given Code

# create an array called websites that has "codewars" as its only value

Solution

def find_average(array):
    return sum(array) // len(array)

See on CodeWars.com