-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathpython_tuples.py
More file actions
59 lines (40 loc) · 1.18 KB
/
python_tuples.py
File metadata and controls
59 lines (40 loc) · 1.18 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
# --------------------------------------------------------------------------------
#Program 1
tup1=('Eleven','Twelve','Thirteen')
print('Before adding',tup1)
list1=list(tup1)
list1.append('Fourteen')
tup1=tuple(list1)
print('After append',tup1)
# --------------------------------------------------------------------------------
#Program 2
tup1 = ('Y','u','v','r','a','j')
lst = list(tup1)
string=''.join(lst)
print(string)
# --------------------------------------------------------------------------------
#Program 3
tup = ('H','i')
tup1 = tup
print(tup1)
# --------------------------------------------------------------------------------
#Program 4
tup1 = (2,3,4,5,6,7)
lst = list(tup1)
ele = int(input("Enter the value you want to remove : "))
if ele in lst:
lst.remove(ele)
tup1 = tuple(lst)
print(tup1)
# --------------------------------------------------------------------------------
#Program 5
tup1=('Yuvraj',19567,'CS')
(name,roll,stream)=tuple1
print(name,'\n',roll,'\n',stream)
# --------------------------------------------------------------------------------
#Program 6
tuple1=('H','i',' ','I','m',' ','Y','u','v','r','a','j')
x1 = tuple1[3]
print(x1)
x2 = tuple1[-4]
print(x2)