-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path022.Tuples_intro.py
More file actions
53 lines (42 loc) · 779 Bytes
/
022.Tuples_intro.py
File metadata and controls
53 lines (42 loc) · 779 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
#Tupples are immutable
#all lists operation can be performed on tupples
#tupples are printed between ( )
t=("a","b","c")
print(t)
name = "Satyam"
age = 20
print(name,age,"Python",2021)
print((name,age,"Python",2021))
hello = "Welcome to","Year",2021
print(hello)
print(hello[0])
print(hello[1])
print(hello[2])
hello2 = list(hello)
print(hello2)
hello2[0]="This is"
print(hello2)
print()
#unpacking a tupple
a = b = c = d = e = f = 42
print(c)
x,y,z=1,2,76
print(x)
print(y)
print(z)
print("unpacking a tupple")
data = 1,2,76 # data represent a tupple
print(data)
x,y,z=data
print(x)
print(y)
print(z)
print("unpacking a list")
data_list = [12,13,14]
# data_list.append(15) #error
p,q,r=data_list
print(p)
print(q)
print(r)
for t in enumerate("abcdefgh"):
print(t)