#100DaysOfCode in Python Transcripts
Chapter: Days 7-9: Python Data Structures
Lecture: Concepts: what did we learn
Login or
purchase this course
to watch this video and the rest of the course contents.
0:00
So that's Python data structures.
0:02
I hope you enjoyed that little overview of lists,
0:05
tuples, and dictionaries.
0:07
For the next couple of days, you will be working
0:09
through the exercises outlined in the three-day overview
0:15
which was the second video for this lesson set.
0:18
But before we get to that, let's just quickly
0:20
quickly recap everything we've done.
0:23
So for lists, lists can be sorted with sort, go figure.
0:29
And then worked through how to iterate
0:31
over a list using a for loop.
0:35
We also discovered pop.
0:37
Okay, if we remember, pop just returns the item
0:40
in the index specified.
0:41
It actually removes it from your list
0:45
and then returns it.
0:47
del simply deletes it from the list,
0:50
doesn't even return it.
0:51
insert does exactly as its name implies.
0:55
It will insert the second argument
0:58
into the index specified in the first argument.
1:01
And then append will just tack whatever it is
1:04
right on to the end of the list.
1:08
Now immutable tuple, okay, we know that this means
1:12
we can't edit, it can't change, okay.
1:16
So we've got a tuple.
1:17
We've created it using tuple itself, okay.
1:21
Now we print out the contents just so you can see
1:24
that we have the six items in this tuple, my name,
1:30
the letters of my name.
1:31
And then when we try to manually override it
1:34
with a simple list substitution there,
1:38
t[0] we're going to assign the letter m
1:42
and then we get the fact that it's a type error,
1:45
it's a tuple.
1:46
You cannot change it, it's immutable, okay.
1:51
Now onto dictionaries.
1:52
We created it manually.
1:54
We manually created a dictionary, okay, simple.
1:58
And then this is how you return the keys using .keys.
2:02
Okay this is just the keys at the front, just the names.
2:07
Then we returned the values in the same way
2:09
that we do with the keys.
2:10
We can get just those values, the 30 and the 33s.
2:14
And then we can get everything as a whole.
2:17
We can get each item, so the key and the value.
2:21
We can do that using items().
2:24
And then we showed you how to iterate over,
2:27
over the item itself so we can get the keys
2:30
and the values, not just one or the other.
2:33
And using a forloop, we can then substitute those keys
2:38
and values into some sort of a string,
2:40
into some sort of text.
2:42
And that's really useful, something you'll probably do
2:44
quite a lot.
2:48
Okay, your turn.
2:49
So for this next couple of days,
2:51
as we discussed in the ReadMe earlier,
2:53
we are going to work through the code challenges bite
2:58
that you have a free code for so go ahead and use that.
3:01
And then for day three, you're going to work
3:04
through that data.py file which in the repo.
3:07
So if you have any sort of thoughts on that
3:09
or any confusion on that, just head back to video two
3:12
where you look at the ReadMe and there's a good
3:16
explanation there as to what you're going to do
3:18
for days two and three.
3:20
So that's Python data structures.
3:22
I hope you enjoyed it.
3:24
Keep calm and...