[ create a new paste ] login | about

Link: http://codepad.org/dhWEAubl    [ raw code | output | fork ]

jonlyles - Python, pasted on Nov 9:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
num_list=[3,5,1,9,55]

num_list = sorted(num_list)
print num_list

if len(num_list) % 2 != 0:
  print "odd list"
  middle = (len(num_list)/2)
  median = num_list[middle]
else:
  print "even list"
  print len(num_list)
  median = (num_list[ (len(num_list) / 2) ] + num_list[ (len(num_list) / 2)-1 ])/2
  
print median


Output:
1
2
3
[1, 3, 5, 9, 55]
odd list
5


Create a new paste based on this one


Comments: