forked from anmolkumari/Python_4_DataScience
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtuples.py
More file actions
54 lines (40 loc) · 650 Bytes
/
tuples.py
File metadata and controls
54 lines (40 loc) · 650 Bytes
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
# This is about Tuples
# tuples
# sequences
#immutable->unchangable,unupdatble, un deletable,un removable
#what is immutable in python->string, tuple, number
#declared in ()
#indexed
#sliced
#list->[]
#tuple->()
#dictionary->{}
#declare
tup=(1,2,3)
print(tup)
#update
#tup[0]=4
print(tup)
# not possible, since it in immutable
#concat
tup2=(4,5,6)
tup1=(1,2,3)
tup3=tup1+tup2
tupc=(1,)
print(tupc)
print(tup3)
#indexed
print(tup2[0])
print(tup3[2])
#slicing
print(tup2[1:3])
print(tup1[2:3])
print(tup3[-4:])
#how to make a tuple from a tuple
tupnew=tup2[1:3]
print(tupnew)
an=(1,)
print(an)
# traversal
for x in tup3:
print(x)