Hello and welcome to this video.
What are modules.
A python module is basically a python file that can contain various types of objects like functions
global variables list dictionaries and other types of objects.
A module is like a code library creating a module is fairly straightforward or you need to do is create
a python file and then you add whatever objects you want into that file so you can add a function you
can add a dictionary.
You could add a variable and any other types of object you want to include in your module.
So the first thing I'm going to do is create a new python file.
So I'm going to right click on my directory and go new click on python file and I'm going to call this
salute and click Okay.
So now I have created a new python file called Salute.
So what I'm going to add into this file I'm going to add a function and I'm going to add a dictionary
but you can add as many things as you want so you can have several functions that do different things
and order types of data structures depending on what it is you want to include.
So let me start by creating a very simple function.
I'm going to create a function chord C on the score.
Hello.
And I'm going to pass in one parameter which is going to be a name parameter and then I will add my
colon and tab down and I had a print function.
So this is what will execute for that function does the function body and inside the parentheses.
I'm just gonna add a simple text that will say hello comma and then I will add a string which will be
the parameter argument that is supplied for the name parameter.
All right.
So when this is called you supply a name that will be appended to this text.
Next thing I want to do is add a dictionary to this module.
So I'm going to create a dictionary.
So I say fruits and I'll say equals two.
And inside my curly braces I'm going to add a key and then a value.
So the key is going to be called name and the value.
I'm going to give it grapes that's one I do a comma and I'll add another key this time I'll make this
one color and I had the value and give it a value of green.
So this is just a very basic example of how you can create a module so you can have as many things as
you want as many functions as you want different kind of variables on all that kind of data structures
you want to include inside your module.
In this video I introduced you to what modules are.
And we also created a basic module.
Thanks for watching and bye for now.