You are on page 1of 4

# list--array tuple set dictionary-map

a = (1,2,3)
# print(type(a))
# print(a)
# print(len(a))

# tuple immutable
# a[2] = 2 # no way

# swap element
# (x,y) = (1,2)
# print(x)
# print(y)
#
# (x,y) = (y,x)
# print(x,y)

# a = 5
# b = 3
# mid = b
# b = a
# a = mid
# print(a,b)

# a = []
# for i in range(10):
# a.append(i+1)
# print(a)
#
# b = [i+1 for i in range(10)]
# print(b)
# a = "hello world"
# print(a.split(' '))
# c = list(a.split(' '))
# print(c)
#
#
# b = ['tom','mary']
# print(str(b))
# print(str(b)[1])

def sortList(L):
a = []
while (len(L) > 0):
a += [min(L)]
L.remove(min(L))
return a
# minVal = L[0]
# for i in range(1,len(L)):
# if L[i] >= minVal:
# pass
# else:
# (minVal, L[i]) = (L[i],
minVal)
# return

def findMed(L):
L = sortList(L)
length = len(L)
if length % 2 == 0:
return (L[length // 2 ] +
L[length // 2 - 1])/2
else:
return L[length // 2]

print(findMed([3,1,2,7,1,3,4]))

You might also like