set
---------
a = set(('10','20','30','40'))
b = set(('30','60'))
u=a.union(b)
i=a.intersection(b)
d=a.difference(b)
sd=a.symmetric_difference(b)
print('u = ',u)
print('i = ',i)
print('d = ',d)
print('sd = ',sd)
dict
---------
d1 = dict()
print(d1)
d2 = dict(p='play',t='talk')
print(d2)
d2['v'] = 'vibe'
d2['d'] = 'docs'
print(d2)
del(d2['v'])
print(d2)
list
-------
emplist1 = list()
print(emplist1)
emplist1.append([9,10])
print(emplist1)
emplist2 = []
print (emplist2)
emplist2 = ['a', 'b', 'c']
print (emplist2)
e=emplist2.pop()
print (emplist2)
print(e)
Tuple
----------
tup1=tuple()
print(tup1)
tup2=tuple('Welcome')
print(tup2)
print('e' in tup2)
print(tup2.count('e'))
print(tup2.index('e'))
print(len(tup2))
Slicing
-------------
k = [3, 4, 5, 6, 7, 8, 9]
print(k[::2])
print(k[0:4])
print(k[1:10:2])
---------
a = set(('10','20','30','40'))
b = set(('30','60'))
u=a.union(b)
i=a.intersection(b)
d=a.difference(b)
sd=a.symmetric_difference(b)
print('u = ',u)
print('i = ',i)
print('d = ',d)
print('sd = ',sd)
dict
---------
d1 = dict()
print(d1)
d2 = dict(p='play',t='talk')
print(d2)
d2['v'] = 'vibe'
d2['d'] = 'docs'
print(d2)
del(d2['v'])
print(d2)
list
-------
emplist1 = list()
print(emplist1)
emplist1.append([9,10])
print(emplist1)
emplist2 = []
print (emplist2)
emplist2 = ['a', 'b', 'c']
print (emplist2)
e=emplist2.pop()
print (emplist2)
print(e)
Tuple
----------
tup1=tuple()
print(tup1)
tup2=tuple('Welcome')
print(tup2)
print('e' in tup2)
print(tup2.count('e'))
print(tup2.index('e'))
print(len(tup2))
Slicing
-------------
k = [3, 4, 5, 6, 7, 8, 9]
print(k[::2])
print(k[0:4])
print(k[1:10:2])
No comments:
Post a Comment