-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathListsProperties.py
More file actions
74 lines (56 loc) · 1.3 KB
/
Copy pathListsProperties.py
File metadata and controls
74 lines (56 loc) · 1.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# MUTABLE values can be changed after initialization
l1=[1,2,34,"a","b","b","2","#@@"]
l2=["2",3,32,"SDSS",434]
print(id(l1))
print(l1)
l1[3]=323232 # changes value at 3rd index to 323232
print(id(l1))# SAME as before
print(l1)
#MEMBERSHIP
print("b" in l1) # RETURN TRUE AS present at 4th index
#ITERABLE
for i in l1:
print(i)
#RELATIONAL
print(l1==l2)
print(l1!=l2)
l3=[1,2,3,4]
l4=[1,2,3]
l5=[1,2,3,567]
l6=[1,2,3,"Aadads"]
print(l3>l4)
print(l4<l5)# True
print(l4==l5) # 1=1 2=2 3=3 but len(l4) != len(l5)
print(l5==l6)#Type error as str and int not commparable
print(l3==l5)# 1=1 2=2 3=3 4>0
print(l3>=l4)#true as l3>l4
#CONCATINATE REPLICATE if used l+=[3] or extend append then same id but l=l+[3] it make new SAME WITH +
print(l1)
print(l1*23)# replicate
print(l1+l2+l3+l4)
#IDENTITY
l=[1,2,3,4,5]
m=[1,2,3,4,5]
b=l
print(b==l)#check content False
print(l is b)#check id True
print(l==m)#check conttent True
print(l is m)#ceck id False
a = [1]
b = a
b.append(2)
print(a) # [1, 2]
print(b) # [1, 2]
print(a is b) # True
#INDEXING
l=[1,2,3,4,5,6,6,6,7,7,89,90]
print(l[4])
print(l[-3])
print(l[6])
#print(l[65])#INdexERROr
#SLICING
print(l[1:])
print(l[1:5])
print(l[2:9:3])
print(l[::-1])#reverse
print(l[-len(l):-4])