Another really useful module that you might use actually quite often in your programming career is the
date time module.
And as the name suggests, it allows us to manipulate date values, which is really, really useful.
So let me just show you quickly how that would work.
I can say from date time.
And in here, well, there is a ton of functionality, but you can do simple things like date time,
dot time.
And give it and here some options.
Oh.
And make sure I import here like that.
So that now if I look at time.
Print here if I click Run.
I get a time of zero.
But if I in here, let's say I do, the time is 545 and let's say 2 seconds if I click Run.
I get 545 and 2 seconds, I get the time.
So I can create time objects here, which is really, really nice.
Another useful one is the date.
And date gives us some really useful things like today.
Hey.
What's today?
Well today.
Hint, hint.
This is when I'm recording this video.
So I get a date object that I can now use, which is really useful.
Maybe a user signs up for your startup and you want to make sure that when they sign up you want to
keep track of what day they started on.
Maybe they got a membership and it expires in 30 days.
Well, we can use the date time module to keep track of that and there's lots of things that we can
do with dates.
As you can imagine, there's things like time zones and different time data that we can manipulate very,
very useful.
I almost forgot this one.
But remember when we built our decorator, our performance decorator, that measures how long of a time
a function takes?
Well, we used a module here, didn't we?
And this is another one of my favorite modules.
It's the time module and we can use it well like this.
It tells us the time and we can use two instances of the time to essentially figure out what the difference
between the time instances are.
Again, another really useful one.
All right.
I think we have time for one more because these videos could last forever.
I could just keep showing you these.
But like I said, these are modules that you're going to use whenever a need arises.
You're going to start Googling and find out, Hey, I need to get date information.
Well, you're going to start Googling and find out that there's a date module or there's a date PI package.
All right.
The last one is called an array.
And we have an array package that we can use from well the array module.
Now in here what is an array.
And this is something that I may have mentioned because lists in Python are sometimes called arrays
in other languages, but there are a little bit different.
You see lists in Python are what we call just dynamic.
That is any time we need data into a list, we can make it as big as we want.
We can just incrementally increase this list and fill up our memory.
And we've seen that before when we tried to, let's say, print out a massive list, arrays that Python
gives us, actually take up less memory and perform faster.
So if you have a large list and let's say you don't want to use generators, you can improve it with
an array.
And that is because when we create an array, it sets how much memory we can use in our machine.
Now, this is a pretty big computer science topic.
You can learn about arrays online or some of my other courses, but for now, the way we would use it
is like this.
We'd say array and we first have to give it a type code.
So a type code with an array is what type of data is this array going to hold?
And this is part of the optimization by telling it what type of data we're going to hold, the memory
is better used.
So for example, if I go to the array.
Module in here, you see that we have different type codes and if I wanted, let's say an integer.
So that is if I want a signed end or maybe I want to float and usually we want something like a signed
int.
So this is a python integer and it shows you what the minimum size in bytes is.
But let's say we just want small numbers so I can say, hey, the type code is going to be I, it's
going to be a signed integer and then I'm just going to give it one, two, three.
So now if I have an array like this.
And I print.
If I click Run.
There you go.
We have an array, but I can access it just like I would a list.
Very, very cool.
And this is a little bit more performance than lists.
Again, if you don't want to use generators, if you have a massive list, this is a quick, easy way
to optimize your code.
The possibilities are endless.
There are so many packages that we can use, so many built in tools.
The key thing is searching for it and looking for it when the problem arises.
But there's no way that you can memorize all of these as you progress through your career.
There'll be certain ones that keep coming up that you'll just get used to, but you just have to trust
me on this.
This is one of those things that just comes with experience and as you code more and more so the best
way to learn these is to just keep coding.
I'll see you in the next one.
Bye bye.