﻿1
00:00:02,048 --> 00:00:04,352
‫Now let's move on to list

2
00:00:06,144 --> 00:00:08,704
‫Lists are very similar to string

3
00:00:08,960 --> 00:00:11,776
‫Except that each element can be of any type.

4
00:00:12,032 --> 00:00:14,080
‫In a string each element

5
00:00:14,336 --> 00:00:15,616
‫Was the character

6
00:00:16,384 --> 00:00:17,664
‫But in  list

7
00:00:17,920 --> 00:00:19,968
‫Each element can be of any type.

8
00:00:21,248 --> 00:00:25,088
‫So to define a list we have to use square bracket

9
00:00:25,344 --> 00:00:29,440
‫So if I write L1 L1 is a variable name

10
00:00:29,696 --> 00:00:34,560
‫Then in a square bracket if I write 1234

11
00:00:37,632 --> 00:00:39,168
‫12345

12
00:00:39,680 --> 00:00:40,704
‫And run this

13
00:00:40,960 --> 00:00:42,752
‫L1 is our list.

14
00:00:43,776 --> 00:00:45,824
‫To check right type

15
00:00:49,408 --> 00:00:50,176
‫L1

16
00:00:52,736 --> 00:00:56,576
‫It is showing that the type of L1 character is list

17
00:00:57,600 --> 00:01:01,696
‫To print all its value we write print L1

18
00:01:07,584 --> 00:01:10,656
‫And we are getting all the values that L1 is containing

19
00:01:13,472 --> 00:01:19,616
‫Just like strings we can also use the same ####### techniques to manipulate list.

20
00:01:20,128 --> 00:01:21,408
‫So if I write

21
00:01:22,432 --> 00:01:23,968
‫L1

22
00:01:24,224 --> 00:01:26,016
‫Square bracket

23
00:01:27,040 --> 00:01:27,808
‫Zero

24
00:01:30,112 --> 00:01:31,136
‫This will give me

25
00:01:31,648 --> 00:01:35,488
‫Element present at the 0th location Which is one

26
00:01:35,744 --> 00:01:40,864
‫So here one is that location 0,2 is at the location

27
00:01:41,376 --> 00:01:41,888
‫1

28
00:01:42,400 --> 00:01:44,448
‫3 is at location 2

29
00:01:44,704 --> 00:01:47,008
‫4 at 3 and 5 at 4.

30
00:01:47,776 --> 00:01:52,384
‫Just like a string I can use colon to select multiple

31
00:01:52,640 --> 00:01:53,664
‫Element

32
00:01:53,920 --> 00:01:56,480
‫If I write 0 colon 3

33
00:01:58,528 --> 00:02:00,832
‫Will give me the first 3 elements

34
00:02:01,088 --> 00:02:04,160
‫Here the location 3 is excluded so I will get

35
00:02:04,416 --> 00:02:05,184
‫Elements

36
00:02:05,440 --> 00:02:09,792
‫Present at location 0, location 1 and location 2

37
00:02:10,048 --> 00:02:11,328
‫3 is excluded

38
00:02:11,584 --> 00:02:14,144
‫Just like slicing in a string

39
00:02:14,400 --> 00:02:16,192
‫You can also use step

40
00:02:16,704 --> 00:02:19,008
‫So if I write L1

41
00:02:20,544 --> 00:02:25,152
‫Now if I want to select all the elements I will just right colon

42
00:02:25,664 --> 00:02:27,456
‫Then I will write another colon

43
00:02:28,224 --> 00:02:34,368
‫So first argument was for the starting location second argument was for the

44
00:02:34,624 --> 00:02:38,208
‫Stopping location and the third argument is for the steps.

45
00:02:38,464 --> 00:02:43,328
‫We are not giving starting and stopping location since we want all the elements.

46
00:02:43,584 --> 00:02:46,144
‫Now we are defining step as two

47
00:02:46,400 --> 00:02:49,728
‫So it will give me all the alternate elements of my list

48
00:02:52,032 --> 00:02:57,920
‫So again it is ignoring 2 and 4 since we provided Step of 2.

49
00:03:01,760 --> 00:03:05,856
‫It is not necessary for list to have all the elements of same type

50
00:03:06,880 --> 00:03:12,256
‫You can assign different types of element in a single list so if I write L2

51
00:03:12,512 --> 00:03:13,536
‫Equal to

52
00:03:14,048 --> 00:03:14,816
‫Square bracket

53
00:03:15,072 --> 00:03:15,840
‫1

54
00:03:16,096 --> 00:03:16,864
‫Comma

55
00:03:17,888 --> 00:03:21,728
‫I want to provide a string I will write in double quotation

56
00:03:21,984 --> 00:03:22,496
‫A

57
00:03:24,544 --> 00:03:29,664
‫Comma if I want to provide floating point numbers I will write 1.0

58
00:03:30,944 --> 00:03:31,968
‫And if I run this

59
00:03:34,528 --> 00:03:40,672
‫My ######## is created and the data type of my first element is ####### second element is a string and the

60
00:03:40,928 --> 00:03:41,952
‫third ####### is #######

61
00:03:44,000 --> 00:03:45,280
‫But we can assign

62
00:03:45,536 --> 00:03:48,096
‫All this in a single list as well.

63
00:03:50,912 --> 00:03:57,056
‫So if you want to check you can check using the type operators write type

64
00:03:57,312 --> 00:04:03,456
‫Now inside L2 I want the data type of first elements I will write zero

65
00:04:04,992 --> 00:04:08,064
‫And it is end because one is our end

66
00:04:08,832 --> 00:04:11,392
‫If I write type

67
00:04:12,672 --> 00:04:13,696
‫Do

68
00:04:13,952 --> 00:04:16,256
‫Square bracket 1

69
00:04:17,536 --> 00:04:23,679
‫Which is string because our a is an double quotation and we have provided it as a string

70
00:04:23,935 --> 00:04:25,215
‫write L2

71
00:04:27,007 --> 00:04:31,615
‫Our L2 is a list that's why we just write type of L2

72
00:04:31,871 --> 00:04:33,407
‫It will showing us list.

73
00:04:34,943 --> 00:04:39,807
‫We can also provide list as a element of another list

74
00:04:40,063 --> 00:04:43,135
‫So we write L3 equal to

75
00:04:45,951 --> 00:04:46,719
‫L2

76
00:04:49,023 --> 00:04:50,303
‫Comma

77
00:04:50,815 --> 00:04:51,583
‫1

78
00:04:53,375 --> 00:04:54,399
‫Comma

79
00:04:54,655 --> 00:04:55,679
‫2.0

80
00:04:58,239 --> 00:05:00,287
‫If you run this command

81
00:05:00,543 --> 00:05:02,079
‫So we have provided list

82
00:05:02,335 --> 00:05:06,175
‫L2 list inside L3 so if we print L3

83
00:05:08,991 --> 00:05:13,343
‫Here our first element is a list which is L2

84
00:05:14,111 --> 00:05:17,695
‫and our second element is int and third element is

85
00:05:17,951 --> 00:05:18,463
‫float.

86
00:05:19,231 --> 00:05:21,279
‫So just to check if we write

87
00:05:22,303 --> 00:05:23,071
‫Type of

88
00:05:23,327 --> 00:05:26,143
‫L3

89
00:05:27,679 --> 00:05:29,215
‫Comma zero

90
00:05:29,983 --> 00:05:34,591
‫This is showing us a list because we have provided L2 inside of L3

91
00:05:36,127 --> 00:05:36,639
‫Now

92
00:05:37,407 --> 00:05:40,991
‫We are mentioned how to select the first element of L3

93
00:05:41,247 --> 00:05:42,783
‫We can just write L3

94
00:05:43,295 --> 00:05:45,087
‫And in bracket we can write 0.

95
00:05:46,111 --> 00:05:50,719
‫This will give us the first element of my first element is a list

96
00:05:50,975 --> 00:05:53,791
‫How to select first element of that list?

97
00:05:54,303 --> 00:05:55,327
‫We can write

98
00:05:55,583 --> 00:05:56,351
‫L3

99
00:05:59,167 --> 00:06:02,239
‫Square bracket I will first write zero

100
00:06:02,495 --> 00:06:05,055
‫Right now I am exercising

101
00:06:05,311 --> 00:06:07,103
‫My first element which is the list

102
00:06:07,359 --> 00:06:10,943
‫Now if I want the second element of this list

103
00:06:11,455 --> 00:06:14,015
‫I will write in a square bracket 1

104
00:06:15,039 --> 00:06:17,343
‫If I run this command it will give us

105
00:06:18,111 --> 00:06:21,951
‫Character A this type of list are called

106
00:06:22,207 --> 00:06:26,047
‫Nested lists because we have list inside a list.

107
00:06:28,095 --> 00:06:33,215
‫Now you can also create list using special functions such as #######

108
00:06:33,471 --> 00:06:35,775
‫If I write list

109
00:06:37,311 --> 00:06:40,639
‫And in bracket write range

110
00:06:40,895 --> 00:06:45,759
‫In range I have to provide starting point stopping point #######

111
00:06:46,015 --> 00:06:52,159
‫So if I provide 0 as my starting point 10 as my stopping point

112
00:06:52,415 --> 00:06:53,951
‫And step as

113
00:06:54,463 --> 00:06:55,231
‫2

114
00:06:56,511 --> 00:06:57,791
‫And if I run this

115
00:06:58,047 --> 00:07:00,607
‫Range will provide me an output

116
00:07:01,375 --> 00:07:04,447
‫Of 02468

117
00:07:04,959 --> 00:07:10,079
‫And I am using list keyword to convert this output in the form of

118
00:07:10,335 --> 00:07:10,847
‫List.

119
00:07:12,639 --> 00:07:16,735
‫So we can create another variable l4 equal to

120
00:07:20,831 --> 00:07:22,367
‫List

121
00:07:22,879 --> 00:07:27,743
‫Range 0 to 10 with step 2.

122
00:07:33,375 --> 00:07:36,703
‫If we print a variable l4

123
00:07:39,775 --> 00:07:42,847
‫We can see zero is our first element

124
00:07:43,615 --> 00:07:47,199
‫246 and then 8 if you want to sort it

125
00:07:47,967 --> 00:07:52,575
‫The descending order we'll write L4 as sort, sort is a function

126
00:07:53,087 --> 00:07:59,231
‫And the argument here is Reverse equal to true if you don't give this reverse  equal to true

127
00:07:59,487 --> 00:08:04,095
‫It will automatically sorted in the ascending order but we want it in the descending order

128
00:08:04,351 --> 00:08:07,423
‫That's why we are providing argument rivers equal to true

129
00:08:07,935 --> 00:08:09,727
‫Now if we check L4

130
00:08:09,983 --> 00:08:10,751
‫You can see

131
00:08:11,519 --> 00:08:16,383
‫It is sorted in the descending order or first element is 8 which is the

132
00:08:16,639 --> 00:08:17,407
‫Largest

133
00:08:17,663 --> 00:08:20,735
‫And the last element is zero the smallest element.

134
00:08:23,551 --> 00:08:26,367
‫If you want to add more elements into

135
00:08:26,623 --> 00:08:27,391
‫Our list

136
00:08:27,903 --> 00:08:33,279
‫We can use append function will write L4

137
00:08:33,535 --> 00:08:34,815
‫Dot append

138
00:08:37,631 --> 00:08:38,655
‫And in bracket

139
00:08:38,911 --> 00:08:40,191
‫Mentioned

140
00:08:40,447 --> 00:08:41,215
‫Variable

141
00:08:41,471 --> 00:08:43,263
‫Here we are writing pen

142
00:08:45,311 --> 00:08:46,591
‫This

143
00:08:46,847 --> 00:08:47,615
‫Add

144
00:08:47,871 --> 00:08:50,431
‫The value 10 at the end of the list

145
00:08:50,687 --> 00:08:51,711
‫You can see

146
00:08:52,223 --> 00:08:54,271
‫We have 10 at the end of the list

147
00:08:55,295 --> 00:08:59,903
‫If you want to change value of any element we can just write

148
00:09:00,927 --> 00:09:05,279
‫That element address so L4 square bracket zero

149
00:09:06,815 --> 00:09:10,911
‫This is our first element and we want the value of this element

150
00:09:11,167 --> 00:09:14,751
‫To be three equal so if we write equal to 3

151
00:09:15,519 --> 00:09:18,079
‫It will automatically change the value of

152
00:09:18,591 --> 00:09:20,127
‫Of the first element to 3

153
00:09:20,383 --> 00:09:23,455
‫So there it was it now the value is 3

154
00:09:26,015 --> 00:09:30,879
‫If you want to change values of multiple elements we can write

155
00:09:31,647 --> 00:09:32,671
‫L4

156
00:09:34,207 --> 00:09:38,303
‫I want to change the value of second and third will write one

157
00:09:40,607 --> 00:09:45,215
‫Colon three this means element second and third

158
00:09:45,471 --> 00:09:47,263
‫since 3 is not included

159
00:09:48,543 --> 00:09:49,823
‫And one is included.

160
00:09:50,335 --> 00:09:52,383
‫And then in the square bracket

161
00:09:53,919 --> 00:09:57,759
‫You can write the values for ignore if we write 5, 7

162
00:10:00,063 --> 00:10:06,207
‫Now we are replacing this 6 to 5 in this 4 to 7 so we'll run this and

163
00:10:09,023 --> 00:10:11,583
‫You can see the values are now changed.

164
00:10:12,351 --> 00:10:17,471
‫In a way we are providing another list to replace the elements of this list.

165
00:10:21,567 --> 00:10:25,919
‫Now if you want to insert an element at an specific index

166
00:10:26,175 --> 00:10:31,551
‫Will do this by using a Keyword insert if we right L4

167
00:10:32,063 --> 00:10:33,855
‫Insert

168
00:10:34,623 --> 00:10:36,415
‫And we want to insert

169
00:10:36,671 --> 00:10:39,999
‫This element at the first position will write zero

170
00:10:40,511 --> 00:10:41,791
‫since 0 is our 1st

171
00:10:42,303 --> 00:10:45,375
‫Position will write 15.

172
00:10:46,655 --> 00:10:52,543
‫If we write 15 in double quotation this means we are passing this element as a string

173
00:10:52,799 --> 00:10:54,847
‫So let's do this

174
00:10:59,455 --> 00:11:00,223
‫You can see

175
00:11:00,479 --> 00:11:03,039
‫We have inserted this 15 string

176
00:11:03,807 --> 00:11:08,415
‫At the first position now all my other elements

177
00:11:08,671 --> 00:11:10,719
‫are shifted by one space

178
00:11:10,975 --> 00:11:17,119
‫Now if you want to remove element of this string we can do this

179
00:11:17,375 --> 00:11:22,751
‫By using two commands first visit remove function and the second is the delete function

180
00:11:23,263 --> 00:11:29,407
‫Remove function will remove the value of that element so for example if I write remove

181
00:11:30,175 --> 00:11:36,319
‫Bracket 3 and 4 dot remove bracket 3 it will first search the element

182
00:11:36,575 --> 00:11:37,855
‫Which have the value 3

183
00:11:38,367 --> 00:11:43,743
‫That is this is the second element so it will delete this second element from this.

184
00:11:46,303 --> 00:11:49,119
‫Whereas if I am using delete

185
00:11:49,631 --> 00:11:52,447
‫It will delete the position of that element

186
00:11:52,703 --> 00:11:53,983
‫So for example

187
00:11:54,495 --> 00:11:55,519
‫if we write

188
00:11:55,775 --> 00:11:56,543
‫Dell

189
00:11:56,799 --> 00:11:58,591
‫,L4

190
00:11:59,615 --> 00:12:05,759
‫And then I have to specify the location so if I write zero that means the first location

191
00:12:06,271 --> 00:12:08,575
‫Will be deleted

192
00:12:09,343 --> 00:12:10,879
‫we'll run L4

193
00:12:11,647 --> 00:12:14,463
‫Can see the ###### is now deleted

194
00:12:14,719 --> 00:12:15,487
‫We are only

195
00:12:15,999 --> 00:12:19,071
‫Only 5 7 2 10 are remaining.

196
00:12:20,095 --> 00:12:24,959
‫Now if you want to know more about less you can write help

197
00:12:25,471 --> 00:12:31,615
‫Help is a Keyword you can use anywhere you can write help and in bracket

198
00:12:31,871 --> 00:12:34,943
‫You can write list

199
00:12:35,455 --> 00:12:36,991
‫if you run this

200
00:12:38,271 --> 00:12:44,159
‫You will get all the information about list we are not going to discuss all here

201
00:12:44,415 --> 00:12:49,791
‫and just quick tip if you want to remove your output

202
00:12:50,047 --> 00:12:51,583
‫Just select the cell

203
00:12:52,351 --> 00:12:58,495
‫Convert it to low MB and then again convert it to 4 then now your output is ######

204
00:12:59,519 --> 00:13:04,127
‫If you have some large output you can you probably want to do this

205
00:13:04,895 --> 00:13:09,503
‫Now let's move on to tuples, tuples is another data type

206
00:13:10,527 --> 00:13:11,807
‫Provided by Python

207
00:13:18,975 --> 00:13:21,535
‫So tuples are just like list

208
00:13:21,791 --> 00:13:25,119
‫Except that they cannot be modified once created

209
00:13:26,399 --> 00:13:27,935
‫That's why we call them

210
00:13:28,191 --> 00:13:29,471
‫Immutable

211
00:13:29,727 --> 00:13:31,775
‫So tuples are immutable

212
00:13:32,031 --> 00:13:33,311
‫and a list

213
00:13:33,567 --> 00:13:34,847
‫Is mutable

214
00:13:36,383 --> 00:13:39,455
‫So to assign a tuple we use

215
00:13:40,223 --> 00:13:41,247
‫Parenthesis

216
00:13:41,759 --> 00:13:46,367
‫So for list we use square bracket for tuples we use

217
00:13:46,879 --> 00:13:48,671
‫Parenthesis so if you write

218
00:13:48,927 --> 00:13:50,207
‫P

219
00:13:50,975 --> 00:13:52,255
‫Equal to

220
00:13:52,511 --> 00:13:53,791
‫Parenthesis

221
00:13:54,047 --> 00:13:56,095
‫1, 2.

222
00:14:01,727 --> 00:14:03,519
‫If you see

223
00:14:03,775 --> 00:14:06,335
‫When we were out putting the list

224
00:14:06,847 --> 00:14:10,687
‫There were square bracket at the end and at the start

225
00:14:10,943 --> 00:14:13,247
‫But for the tuples we have

226
00:14:13,503 --> 00:14:14,527
‫Parenthesis

227
00:14:15,039 --> 00:14:19,135
‫And we cannot change the values of this elements

228
00:14:20,671 --> 00:14:21,695
‫So

229
00:14:21,951 --> 00:14:22,975
‫Just you try

230
00:14:23,487 --> 00:14:28,095
‫If you want to change the value of first element we can write P1

231
00:14:29,887 --> 00:14:31,935
‫Then square bracket 0

232
00:14:33,471 --> 00:14:35,007
‫Equal to 5

233
00:14:35,263 --> 00:14:37,567
‫Since this is a tuple

234
00:14:37,823 --> 00:14:43,199
‫Will get an error while running this you can see the error is

235
00:14:43,455 --> 00:14:49,599
‫Tuple object does not support item assignment you cannot change the value of tuple once created.

236
00:14:50,367 --> 00:14:54,463
‫To get the type of the ####### type T1

237
00:14:54,975 --> 00:14:57,023
‫You can see the type is tuple.

238
00:14:58,815 --> 00:15:03,167
‫There are very limited use cases of tuples and we will hardly use tuples

239
00:15:03,935 --> 00:15:07,007
‫In our analysis let's move on to

240
00:15:07,263 --> 00:15:09,567
‫The next data type which is dictionary.

241
00:15:15,711 --> 00:15:18,271
‫Dictionaries are also like list

242
00:15:18,783 --> 00:15:22,111
‫Except that each element is a key value pair

243
00:15:22,879 --> 00:15:28,767
‫And the syntax for assigning dictionaries is using curly brackets in a list

244
00:15:29,279 --> 00:15:35,423
‫We use the square bracket in tuple we use parentheses in dictionaries will

245
00:15:35,679 --> 00:15:36,959
‫Curly bracket.

246
00:15:37,727 --> 00:15:38,239
‫So

247
00:15:38,495 --> 00:15:39,263
‫in our list

248
00:15:40,543 --> 00:15:46,687
‫There are indexes starting from 0 1 2 3 4 here you can say that you are

249
00:15:46,943 --> 00:15:52,831
‫You are assigning this indexes on your own so for each element you have to assign an index

250
00:15:53,087 --> 00:15:54,367
‫Which we call a key.

251
00:15:54,879 --> 00:16:01,023
‫And the element is called as value that's why we define dictionaries as a collection of key-value

252
00:16:01,279 --> 00:16:02,303
‫Pairs.

253
00:16:02,815 --> 00:16:06,655
‫So to assign a variable B1

254
00:16:08,447 --> 00:16:11,519
‫Which is the dictionary will write equal to curly bracket

255
00:16:12,287 --> 00:16:16,639
‫Now here first we have to write the key

256
00:16:16,895 --> 00:16:17,663
‫######

257
00:16:18,431 --> 00:16:22,015
‫And then get colon and the value of this key

258
00:16:22,527 --> 00:16:24,319
‫Which is one

259
00:16:25,599 --> 00:16:27,135
‫Comma

260
00:16:27,391 --> 00:16:28,159
‫key 2

261
00:16:32,767 --> 00:16:34,303
‫So in a list

262
00:16:34,815 --> 00:16:40,959
‫There were indexes 01234 this T1 T2 T3 and just like indexes.

263
00:16:48,895 --> 00:16:50,687
‫if we run this

264
00:16:52,735 --> 00:16:56,575
‫we'll write ###### run this you can see

265
00:16:58,367 --> 00:17:00,927
‫In this we were only getting the values

266
00:17:01,183 --> 00:17:03,743
‫And here we are getting first the keys

267
00:17:03,999 --> 00:17:05,279
‫And then the value.

268
00:17:06,303 --> 00:17:07,839
‫So if you want

269
00:17:08,351 --> 00:17:14,239
‫You can see that type of this D1 write type P1

270
00:17:16,031 --> 00:17:16,799
‫The type is

271
00:17:17,055 --> 00:17:17,823
‫Dictionary.

272
00:17:18,847 --> 00:17:19,615
‫Now

273
00:17:19,871 --> 00:17:23,455
‫If I want to Grab the first value I will write D1

274
00:17:25,503 --> 00:17:27,039
‫And in square bracket

275
00:17:27,295 --> 00:17:29,087
‫I will write keyone.

276
00:17:33,439 --> 00:17:34,719
‫if we run this

277
00:17:35,743 --> 00:17:37,023
‫You can see

278
00:17:38,047 --> 00:17:39,071
‫for the key

279
00:17:39,327 --> 00:17:41,887
‫key1 we have a value of 1

280
00:17:42,143 --> 00:17:42,911
‫In a list

281
00:17:43,679 --> 00:17:48,031
‫We were using directly using the indexes such as 0 1 2 3 4

282
00:17:48,799 --> 00:17:51,359
‫In dictionaries we have to use this keys

283
00:17:51,615 --> 00:17:53,919
‫To get the value of that pair.

284
00:17:56,223 --> 00:17:58,271
‫So

285
00:17:58,783 --> 00:18:04,671
‫if I try to write like this D1 square bracket 0 that is the first element I will get an error

286
00:18:05,439 --> 00:18:10,047
‫I always have to refer this value using the key of this value.

287
00:18:15,167 --> 00:18:17,215
‫So Python also supports

288
00:18:17,471 --> 00:18:19,775
‫Conditional statement such as

289
00:18:20,031 --> 00:18:22,335
‫If, else or else if

290
00:18:22,591 --> 00:18:24,639
‫It also support

291
00:18:25,151 --> 00:18:27,967
‫Loops such as for loop and while loop

292
00:18:28,479 --> 00:18:30,527
‫We are not going to discuss this here

293
00:18:30,783 --> 00:18:32,575
‫If you want you can explore

294
00:18:32,831 --> 00:18:33,343
‫This

295
00:18:33,599 --> 00:18:34,623
‫On your own

296
00:18:35,647 --> 00:18:37,439
‫If needed we will discuss it

297
00:18:38,207 --> 00:18:39,743
‫In our upcoming lectures.

