And just one more thing.
Before we finish this Python section, let's talk about Python modules and see how to use them.
So in Python or any other language you get a core set of functions and keywords.
For example, the print function is part of the core Python functions.
You can use the keyword def to create a function, etc. but this core base is somehow quite limited.
If you want to connect to Gpio or start a web server or anything more complicated, you will have to
write a lot of code all by yourself and this will take forever.
That's why you can use libraries which are called modules in Python.
The libraries contain a set of plug and play functionalities to solve a specific problem.
Usually one library contains different functions.
Later in this course we will use a Python module to use gpios, another one for the camera, etc. you
can also have Python modules to do mathematics operations.
Compute all kinds of statistics.
Well, the number of possibilities is endless.
And here I'm going to show you just one library and one function, you can get from it as an example.
So let's say you want to make your program stop for one second, two second, whatever time you want.
How to do that with just loops, conditions, functions and variables?
Well, that's going to be very hard.
So you can use the module called time.
And with time you can make your program what we call sleep for a specific amount of time.
How to import this time module.
Well you have the import keyword you can see in Python.
So you write import and then the name of the module which here is time.
And just to test that we can just run this program.
And you can see nothing happens.
But if nothing happens if we don't have any error it means that this line was correctly executed.
Now let's say I add a more letters.
So this module doesn't exist.
Now we have a module not found error okay.
No module named with this name.
So you can see if I just write import time.
It's not doing anything because it's actually recognized.
And then in this module time we have a function called time dot sleep, and I can put a integer, for
example, or a float.
I can put one second like this as an integer.
It would also work.
This means that I'm going to make the program stop for one second.
That can be very practical if you want to measure.
For example, I'm coming back to this temperature sensor example.
If you want to get one temperature every second, then you can just use this function here between every
sample that you get.
And just to give you an example, I will print a like that.
And then I will print B after like this.
And if I run let's look at what's happening here on the shell.
So if I run that you have a and then you have B but not immediately okay.
B is coming one second after a.
All right.
So that's one example of one module that we import with one function that we use.
And as we progress with the course we are going to use many more modules that will allow us to use cool
functionalities with Python and the Raspberry Pi.