top of page
learn_data_science.jpg

Data Scientist Program

 

Free Online Data Science Training for Complete Beginners.
 


No prior coding knowledge required!

Writer's pictureAbdelrhman Gaber

Median of sorted Array using python

in this application we pass to our function unsorted list and it will return the median of the list

steps:

1 - First we save the length of the list in a variable called length.

2 - use build in function in python called sort() to return the same list but sorted.

3 - check if we have odd number of elements or even number.

4 - if we have odd numbers the median will be in the middle of the list.

5 - if we have even numbers we take the two numbers in