-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfourthlab.py
93 lines (66 loc) · 1.67 KB
/
fourthlab.py
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
76
77
78
79
80
81
82
83
tupp1=(1,2,3,4,5,(1,2,3,4,5))
list1 = [1,2,3,4,5,(1,2,3,4,5)]
tupp2=(6,7,8,9,10,(6,7,8,9,10))
list2 = [6,7,8,9,10,(6,7,8,9,10)]
print(tupp1[5]+tupp2[5])
print(list1[5]+list2[5])
tupp1=(1,2,3,4,5,[1,2,3,4,5])
list1 = [1,2,3,4,5,(1,2,3,4,5)]
tupp2=(6,7,8,9,10,(6,7,8,9,10))
list2 = [6,7,8,9,10,(6,7,8,9,10)]
#print(tupp1[5]+tupp2[5])
print(list1[5]+list2[5])
# pop will remove the last elemnt from list
print(list1.pop())
#remove function will remove the first occurance of element
list2 = [6,'my',8,"nothing",10,(6,7,8,9,10)]
list2.remove('my')
print(list2)
#clear function willl clear the whole list
list1.clear()
print(list1)
list1 = [1,2,3,4,5,(1,2,3,4,5)]
list2 = [6,'my',8,"nothing",10,(6,7,8,9,10),'my']
#count fun. will count the instance of each element
list3 = [6,7,8,9,10,1,2,3,4,5]
print(list1.count((1,2,3,4,5)))
#reverse method will reverse the list
list1 = [1,2,3,4,5,(1,2,3,4,5)]
list2 = [6,'my',8,"nothing",10,(6,7,8,9,10),'my']
list2.reverse()
print(list2)
#sort inbuilt method for sorting
list3.sort()
print(list3)
list3.sort(reverse=True)
print(list3)
#task
tuppleori=(5,20,3,7,6,8)
listori= [5,20,3,7,6,8]
listori.sort()
print(listori)
tuplsecond= (2,4,5,6,2,3,4,4,7)
listsecond= (2,4,5,6,2,3,4,4,7)
print(tuplsecond.count(4))
print(tuplsecond.count(2))
print(tuplsecond.count(5))
print(tuplsecond.count(6))
print(tuplsecond.count(7))
dict_1={
"a":"A",
"b":"B",
"c":"C",
"d":"D",
"e":"E",
}
print(dict_1)
print(dict_1.get('D'))
print(dict_1.keys())
print(dict_1.values())
print(dict_1.items())
print(dict_1['a'])
#set
myset= {1,2,3,2,42,4,6,3,521,4,1,"a"}
print(myset)
print(myset.add(1))
print(myset)