Solution
listOne = [3, 6, 9, 12, 15, 18, 21]
listTwo = [4, 8, 12, 16, 20, 24, 28]
listThree = list()
oddElements = listOne[1::2]
print("Element at odd-index positions from list one")
print(oddElements)
EvenElement = listTwo[0::2]
print("Element at odd-index positions from list two")
print(EvenElement)
print("Final third list")
listThree.extend(oddElements)
listThree.extend(EvenElement)
print(listThree)
testList = [8, 17, 67, 89, 11, 43, 55]
print("Org. list ", testList)
val = testList.pop(3)
print("Updated List after removing no. at pos. 3 ", testList)
testList.insert(2, val)
print("Now add it at ind. 2 ", testList)
testList.append(val)
print("After Add at last ", tsetList)
Lst1 = [56, 27, 8, 91, 44, 12, 19, 27, 63]
print("Org. ", Lst1)
ln = len(Lst1)
spSize = int(ln/3)
st = 0
end = spSize
for i in range(1, 4, 1):
ind = slice(st, end, 1)
tmpL= Lst1[ind]
print("Part ", i , tmpL)
print("Reversed ", list(reversed(tmpL)))
st = end
if(i != 2):
end +=spSize
else:
end += ln - spSize
tList = [14, 20, 88, 14, 20, 38, 20]
print("list ", tList)
cntDict = dict()
for i in tList:
if(i in cntDict):
cntDict[i] += 1
else:
cntDict[i] = 1
print("Count Detail ",cntDict)
L1 = [2, 4, 6, 8]
print("List 1 : ", L1)
L2 = [4, 8, 12, 16]
print("List 2 : ", L2)
L3 = zip(L1, L2)
res_Set = set(L3)
print("o/p is :",res_Set)
F_Set = {32, 42, 51, 57, 40, 79, 33}
S_Set = {57, 79, 33, 67, 73, 43, 48}
print("First ", F_Set)
print("Second ", S_Set)
x = F_Set.intersection(S_Set)
print("Intersection set ", x)
for i in x:
F_Set.remove(i)
print("First Set after deleting common numbers ", F_Set)
Set_A = {57, 83, 29}
Set_B = {57, 83, 29, 67, 73, 43, 48}
print("A ", Set_A)
print("B ", Set_B)
print("A is subset of B -", Set_A.issubset(Set_B))
print("B is subset of A - ", Set_B.issubset(Set_A))
print("A is Super set of B - ", Set_A.issuperset(Set_B))
print("B is Super set of A - ", Set_B.issuperset(Set_A))
if(Set_A.issubset(Set_B)):
Set_A.clear()
if(Set_B.issubset(Set_A)):
Set_B.clear()
print("A : ", Set_A)
print("B : ", Set_B)
EmpID = [55, 83, 69, 94, 22, 83, 30, 97]
empDict ={'Karan':55, 'shruti':69, 'Iti':22, 'Sunil':97}
print("List -", EmpID)
print("Dictionary - ", empDict)
EmpID[:] = [i for i in EmpID if i in empDict.values()]
print("Updated list ", EmpID)
sale ={'jan':80, 'feb':31, 'mar':81, 'Apr':42, 'May':31, 'Jun':47,
'Jul':73, 'Aug':42, 'Sep':73}
print("Dictionary's values - ", sale.values())
saleList = list()
for val in sale.values():
if val not in saleList:
saleList.append(val)
print("Final :", saleList)
Lst1 = [32, 40, 88, 53, 54, 32, 40, 53]
print("Org: ", Lst1)
Lst1 = list(set(Lst1))
print("unique list", Lst1)
tuple = tuple(Lst1)
print("tuple ", tuple)
print("Minimum : ", min(tuple))
print("Maximum : ", max(tuple))