From b3b895cb670cea6928240dc03eb1ab8b72846bfc Mon Sep 17 00:00:00 2001 From: Angelos Chalaris Date: Fri, 4 Oct 2019 09:13:50 +0300 Subject: [PATCH] Update median.md --- snippets/median.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/snippets/median.md b/snippets/median.md index fb0d5f3ad..1717685d6 100644 --- a/snippets/median.md +++ b/snippets/median.md @@ -2,6 +2,7 @@ title: median tags: math,beginner --- + Finds the median of a list of numbers. Sort the numbers of the list using `list.sort()` and find the median, which is either the middle element of the list if the list length is odd or the average of the two middle elements if the list length is even. @@ -15,6 +16,7 @@ def median(list): else: return list[int(list_length/2)] ``` + ```py median([1,2,3]) # 2 median([1,2,3,4]) # 2.5