Guys welcome back to 100 Days Of Code In today's video we'll talk about 'Modules' & "What is 'pip'? " Basically modules are used to borrow someone else's code Which means you can use someone else's code in your program with the help of modules We have 2 kind of 'Modules' 1. Built-in Modules And the 2nd one is External Modules which are installed using 'pip' 'External Module' is a code written by people And they want you to use their code in your Python program Just understand it like, I'm using this phone And how is it functioning I don't know even then I'm able to use it This is a type of 'External Module' for me I don't know what its implementation are.
But I'm able to use it On the other hand 'Built-in Modules'. . .
. . .
Are the modules which ships along with Python Programming Language Which means there's no need for you to install them externally We use 'Modules' because we don't want to code basics programs from scratch If you're working on a Big Machine Learning Program And you're using AI for. . .
Let us say self-driving car So you don't want to write a program to find the average of 10 numbers Or a program to find the Geometric mean of 10 numbers In that human errors may occur But the code written in 'Modules' is well-tested & written by experts And because many people have used this so there are very less chances for error You can write programs from the scratch for your understanding if you want But if you use 'Modules' so it'll save your time & efforts and you can work on some big projects Let's move to the computer screen and we'll install some 'Modules' & learn how they works Let's get started [STARTING THEME] So guys I'm now in my computer screen And I'll quickly open my Day-3 Repl And here you can see the video which I'm currently recording But because this video is not recorded yet so let me keep it aside But you'll be able to see this video Just telling And along with that I'll adjust this. . .
. So you can adjust it as you please I just quickly want to tell you "What are 'Modules' in Python" Look, whenever you write a code in Python Programming Language So you can write it in 2 manners Either you're writing it on your own Or you can take help from 'Modules' If you've installed Python in your computer And if you go to your terminal And if you write "pip" So you'll be able to see a Utility Because I'm using Mac, so I've to use "pip3" If you're using Linux or Mac so you've to use "pip3" and in Windows you've to use "pip" But you can see as I wrote "pip3" here I've got a lot of stuff here Now if I write "pip3 install pandas" There's no need for you to know about 'pandas' or what am I writing So look "Collecting pandas" is written here It is downloading a package with 1. 1mbps Let me explain what's going on When I write "pip install pandas" so I command my 'pip'.
. . .
. . To install the package with name 'pandas' Now what is 'pandas'?
It is a library of data analysis But let me tell you that you can use a lot of modules like this here Look I've used the 'pandas' here Now let me tell you a very good analogy to explain the difference between Built-in & External Modules When you were a child your mother ask you to buy some groceries. . .
. . .
Or Milk or Yogurt. . .
. . .
Or bread or butter. . .
And whatever you bought was available at your home So basically you were the package manager for you home Whatever the item was needed you bought that from the suitable place and bring it home Same like that 'pip' is a package manager It installs whatever the module you ask for from the internet in your Python interpreter For eg. it has installed the Pandas as you can see Now I can use 'pandas' But does every module needs to be installed? If you need a refrigerator so almost every house owns it And there's no need for you to buy a refrigerator That is a kind of a built-in module.
It is already present in your house Every home has Needle & Thread Every home has Plate & Spoon So these all are like Built-in Modules So there's no need to buy them every time we need them So that's how Built-in & External Modules works So we can install whatever the module we want with the help of 'pip' Now if I write "python3" and if you're using windows so if you write "python" here So you'll be able to see python version 3. 11 Let me zoom it in a little bit Now if I write "import pandas" here so I won't see any error here But now if I write "import sklearn" So I'll see an error "ModuleNotFoundError: No module named 'sklearn' " This happened because this module was not present in my computer Now don't be tensed about what I'm writing. You won't get it I already know I'm just telling you for your understanding.
. . .
. . that "How to grab modules" Now I'll exit the python's Repl by writing "Exit()" Now if I want to install "sklearn" so I'll write "pip3 install scikit-learn" I'll write "sklearn" when I'll use the this package but for installing I'll write "scikit-learn" You can see it is installing and with quite a good speed Now after this if I import 'sklearn' by writing python3 So my job will be done Now it is installing some of its dependencies which may take some time What is 'sklearn'?
A library for Machine Learning Shall we use it now? Not just yet So if I write "sklearn" here So you'll be able to see "Machine Learning Library in Python" We'll do everything, don't mind it We'll bang it Some people are commenting that the course is being very slow. Yeah I know that Tell me this after some days when the difficulty level will rise And there will be absolute understanding I guarantee it.
Just follow me everyday step-by-step Now I want to show you. . .
When it'll be installed. . .
And when I'll write "sklearn". . .
. I want to show you "import sklearn" That "import sklearn" will work here Look when I'll write "import sklearn" it'll work, there won't be any error So now I'll exit it Now this interface which we are able to see by writing "python3" it is called REPL REPL means Read, Evaluate, Print, Loop We won't use it We'll write proper programs We'll directly execute Python scripts And for this I'm using 'Replit' Can you do this without 'Replit'? Absolutely it's possible but I'm using 'Replit' because it is quite convenient So I'll create a file with name "main.
py" And I'll move it's output 'Console' here Can you see as I'm dragging it. . .
. Now I can see my output here You'll be able to see my video here which will be super convenient for you So what I'll write in 'main. py' is.
. . .
I'll write "import pandas" And do you know what's the biggest advantage of using 'Replit'? As I'll run it, It'll detect that 'pandas' is not installed So it'll automatically install it So don't be confused about "Why I didn't get the error" The error didn't occur because for your convenience Replit started installing it automatically Replit wants you to be convenient while you program But you must know the concepts. If you run this here so you'll get the errors as I showed you And look Replit automatically started installing pandas for me because it knows.
. . .
. . That if I import pandas so I definitely want to use it.
So why not install it automatically? Which I find quite great from replit So they have installed the pandas in Python Now let's suppose I write here " print("Hi") " Now if I run it. .
. So 'pandas' has been installed and I'm able to see "Hi" So this is the USP of Replit So for your convenience I've written in text " 'Modules' are like code library which you can use in your program using 'import' keyword" I'll tell you more about this Built-in Module & External Modules are two types of Modules Built-in Modules are modules which ships along with Python Programming language So let's search for "Built-in Modules in Python" And let's look for the modules that are built-in in Python and I don't need to install every-time So look here's the list of those modules You can see here's a module with name "hashlib" Let's try using it. Let try "import hashlib" And let's see when I'll command it "Import hashlib" so will it be installed?
So look as I run it. . .
Look it didn't install. Just simply "Hi" has appeared But on the other hand if I write "import tensorflow" Let me show you when I'll write "import tensorflow" So 'tensorflow' will start installing So look it started installing 'tensorflow' Because 'tensorflow' is not a built-in module it is an external module Which needs to be download from internet that's why it is being installed External modules needs to be installed just like something in your house that's expired You've to buy that everyday like milk But you don't need to buy plate everyday because it's present in your home So plate is like Built-in module and Milk which you buy everyday is like External module It's fun man So look I've told here how to use 'pip' command If you write "pip install pandas" so 'pandas' will be installed You can use this button to copy the code So whatever the code I'm writing here. .
. Just copy this in this way and paste it like this And you'll be able to run it So how 'pandas' function? 'Pandas' is a module which contains read CSV function CSV is a file just like XLS which you can read But don't be in this trap for now I'm just telling you how these things works In the coming days I'll help you to read excel and all.
So don't be tensed about that Now many people are asking which Python tutorial should they follow? So always follow the latest videos because they come with a bang If you find this video latest so follow this And many people ask "Which version of python should I use? " So for those people, Use the latest version If you use Replit so there's nothing for you to tensed about that As long as it's Python 3, Python3.
7 Python3. 11 or 3. 8 There won't be any major difference in them Your programs will work But yes if Python4 or Python5 comes so that may be a major upgrade It "MAYBE", there's no guarantee if some things will remain same in Python4 so that would be interesting to see Never worry about which version of python you must use "Can I use v3.
12 while watching tutorial for v3. 11? " Absolutely you can use it Basics will remain same Now just like we have this terminal, replit have 'Shell' If you write "Python" in 'Shell' So the same interface will be shown look Python3.
8. 12 is installed in it If I write. .
. . " Print("Hello") " "hello" doesn't contain "w" Pal, I know the spelling of "hello" I'll press 'Enter' so look "hello" has appeared here So you get this terminal here And you IDE is built-in in your browser So this makes it quite convenient And I'll also be here.