-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTupleProperties.py
More file actions
75 lines (55 loc) · 1.28 KB
/
Copy pathTupleProperties.py
File metadata and controls
75 lines (55 loc) · 1.28 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
75
# IMMUTABLE values can't be changed after initialization
t1=(1,2,3,4,5,6,6,8,9)
t2=1,2,3,4,5,6,7,8
print(id(t1))# id of t1
print(t1)# prints t1
#t1[3]="23"#ERROOR Immutable
#MEMBERSHIP
print(5 in t1) # RETURN TRUE AS present at 4th index
#ITERABLE
for i in t1:
print(i)
#RELATIONAL
print(t1==t2)
print(t1!=t2)
t3=(1,2,3,4)
t4=(1,2,3)
t5=(1,2,3,567)
t6=(1,2,3,"Aadads")
print(t3>t4)
print(t4<t5)# True
print(t4==t5) # 1=1 2=2 3=3 but len(l4) != len(l5)
print(t5==t6)#Type error as str and int not commparable
print(t3==t5)# 1=1 2=2 3=3 4>0
print(t3>=t4)#true as l3>l4
#CONCATINATE REPLICATE - IMMUTABLE CHANGES ID AFTER +,* creates new oject delete previous
print(t1)
print(t1*23)# replicate
print(t1+t2+t3+t4)
#IDENTITY
l=(1,2,3,4,5)
m=(1,2,3,4,5)
b=l
print(id(l),id(m))
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 ####may vary due to caching
a =(1,)
b = a
b=b+(2,)
print(a) # (1,)
print(b) # (1, 2)
print(a is b) # False
#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])