-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfour.py
More file actions
44 lines (33 loc) · 1.26 KB
/
four.py
File metadata and controls
44 lines (33 loc) · 1.26 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
# -----------------------------------------------LISTS AND TUPLES-------------------------------------------------------
friends = ["Apple", "Orange", 5, 345.06, False, "Aakash", "Rohan"]
print(type(friends))
# -----------------------------------------------LIST INDEXING-------------------------------------------------------
print(friends[0])
friends[0] = "Grapes" # Unlike Strings lists are mutable
print(friends[0])
print(friends[1:4])
# -----------------------------------------------LIST METHODS.-------------------------------------------------------
print(friends)
friends.append("John")
print(friends)
l1 = [1, 34,62, 2, 6, 11]
l1.sort()
l1.reverse()
l1.insert(2, 333333) # Insert 333333 such that its index in the list is 3
print(l1)
value = l1.pop(3)
print(value)
l1.remove(2)
print(l1)
# -----------------------------------------------TUPLES IN PYTHON-------------------------------------------------------
a = () # empty tuple
a = (1,) #tuple with only one element needs a comm
a = (1,45,342,3424,False, "Rohan", "Shivam") # tuple with more than one element
print(a)
print(type(a))
# -----------------------------------------------TUPLE METHODS-------------------------------------------------------
no = a.count(45)
print(no)
i = a.index(3424)
print(i)
print(len(a))