By Anurag Singh
Hi, In this tutorial we are going to learn, how to use modules, what is the importance of modules and what is pip.
By using Modules, we can use code written by someone else in our program, and by doing this we can save our time. Today, we are going to learn about modules and pip in python.
Note - Using modules in our code is legal and also free of cost.
Let us understand what are modules and pip in python are:-
Module – Module is a part/stack of codes that have definitions of several functions, classes, variables, etc., which is written by other programmers to help other coders or programmers and make their work easier and faster.
Pip – The role of pip in python is as a package manager. To download an external module in python we use the pip command.
Installing of the module in our PC by using the pip ou package manager :
1. First of all we have to Open our command prompt/Powershell window on our PC.
2. And then just type pip installs "module_name" and press enter, pip will manage everything.
3. Once we do that, our module will start downloading and it will install automatically on our PC.
For example, I am going to install flask, and here is the demo:-
(I am downloading flask, you can download whatever module you want to install.)
After pressing the enter key, we will see something like this, which means that our desired module is now installing:-
After showing successfully installed in command prompt, its means that now we can use this module in our python code by typing "import flask(or any module_name)"
More on Python Modules
There are two types of modules in python, first one is Buil-in modules and the second one is External modules
Built-in modules have come with python itself, there is no need to download them externally using pip. Ex- random, os, etc
External modules do not come with python, So we have to download them externally by using pip. There are a bunch of external modules available like Pandas, flask, pygame, etc
I am also sharing a link so that you can see various types of built-in modules of python and also use them wisely.
NOTE: Documentation is always the best place to learn in the programming field, best some documentations are also a little bit confusing for beginners. Keep both things in mind.
This is all about Python modules. I hope you enjoy my tutorial on Python Modules.
Submitted by Anurag Singh (adamaspaul99)
Download packets of source code on Coders Packet