# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: Python 3
#     language: python
#     name: python3
# ---

# ## List
# - append()
# - clear()
# - copy()                   -->make deep copy
# - count()
# - extend ()                -->in memory operation
#     - list1 +list2
#     - list1.__add__
# - index()
# - insert
# - pop
# - remove
# - reverse
# - sort

print(len(dir(list)))
#dir(list) #uncomment to see all avaliable methods

# +
#help(list)  #uncomment to observe all list methods
# -

name = 'Qasim'
name

name1 = 'Ali'
name2 = 'Raza'
name3 = 'Qasim'
print(name1,name2,name3)

# +
#          0       1       2
names = ['Ali', 'Raza', 'Qasim']
#          -3      -2      -1

names.
print(names[1])
print(names[-1])
# -

print(type(name1))
print(type(names))

l1 = []
l1.append('A')
l1.append('B')
l1.append('C')
print(l1)

print(l1)
l1.clear()
print(l1)

l1 = ['A','B','C']
print(l1)
del l1
print(l1)

l1 = ["Qasim",'Hassan','Ali']
l2 = l1   # shalloow Copy address same
print(id(l1))
print(id(l2))


l3 = l1.copy() # deep copy address change
print(id(l1))
print(id(l3))

l3[0] = 'Pakistan'
print(l3)
print(l1)

l1 = ['A','B','C','D','A','A']
l1.count('A')

# +
l1 = ['A','B','C']
l2 = ['X','Y','Z']

print(l1 + l2) # Inline Operation
print(l1,l2)

# +
l1 = ['a','b','c']
l2 = ['x','y','z']

print(l1,l2)
print(l1.__add__(l2)) # Inline Operation
print(l1,l2)

# +
l1 = ['a','b','c']
l2 = ['x','y','z']

l1.extend(l2)
print(l1)
print(l2)

# +
l1 = ['a','b','c']

print(l1.index('c'))

# +
l1 = ['A','B', 'C', 'D','E','B','C']

l1.index('C',3)

# +
l1 = []

l1.insert(0,'A') # ['A']
l1.insert(0,'B') # ['B','A']
l1.insert(0,'C') # ['C','B','A']
print(l1)
l1.insert(1,'Pakistan')
print(l1)

# +
l1 = ['A','B','C']

del l1[-1] # ['A','B']
del l1[-1] # ['A']
l1

# +
l2 = []
l1 = ['A','B','C','D']

a = l1.pop() # D
l2.append(a) # ['D']

a = l1.pop() # C
l2.append(a) # ['D','C']

a = l1.pop() # B
l2.append(a) #['D','C','B'] 

print(l1)
print(l2)

# +
l2 = []
l1 = ['A','B','C','D']

a = l1.pop(1) # B
l2.append(a) # ['B']

a = l1.pop(1) # C
l2.append(a) # ['B','C']

a = l1.pop(1) # B
l2.append(a) #['B','C','D'] 

print(l1)
print(l2)
# -

l1 = ['A','B','B']
l1.remove('B')

l1

l1 = ['A','B','C','D']
l1.reverse()
l1

l1 = ['X','Y','Z','A','B']
l1.sort()
l1

l1 = ['X','Y','Z','A','B']
l1.sort(reverse=True)
l1

# ### Magic or Dunder Methods

# + active=""
# __class__
# __contains__()
# __doc__
# __delitem__()
# __eq__()
# __le__()
# __ge__()
# __sizeoff__()
# -

print(l1)
l1.__class__

l1 = ['X','Y','Z','A','B']
print(l1)
l1.__contains__('A')

l1.__doc__

print(l1)
l1.__delitem__(1)
l1

[1,2,3].__eq__([3,2,1]) # equal

[1,2,3].__le__([3,2,1]) #less then

[1,2,3].__sizeof__()

[1,2,3].__sizeof__

# ## Tuples`

l1 = ['A','B','C']
print(l1)
l1[0] = 'Pakistan'
print(l1)

l1 = ('A','B','C')
print(l1)
l1[0] = 'Pakistan'
print(l1)

l1 = ('A',5,'B','A','A','A')
l1

l1 = ('A',5,'B','A','A','A')
l1.count('A')

l1 = ('A',5,'B','A','A','A')
l1.index('A',1)

help(tuple)



StarcoderdataJupyterScriptsDedupFiltered