Library in Python

Python library is basically a set of functions and methods which allows us to perform many actions without a code. So here, before moving further I’ll assume that everyone is familiar with python basics.

We can modify library in

Functions: It is just a code which we write in a file called program file. So, before running those functions you’ll have to load that program file/module.Program file contains code which is a Function/method.Program file is nothing but a command.

Module: In O.S world, code is known as program file but in programming world, we call it a Module. This comes from library which you need to install sometimes or it may be already installed in your python.In any language world, all these functions come from a program file which is also known as a Module. Sometimes, the Module name or Library name can be different.From Data science or Machine learning world, we also use pandas, numpy or matplotlib.

Software: Whatever files we have in the system it always comes from software whether its a normal file or program file.In Windows O.S, we have software and a program file appears which contains all the functions.This is further known as Library.

In O.S, we use word ‘Software’, in mobile,we use word ‘apps’, in programming world, we use ‘Library’.

Speaking about it in brief, I would like to take an example-We have to use array function to convert list into array.

name = [['abcd,' 'hi@nh.com'], ['bcde,' 'hj@hg.com'], ['cdef,' 'bd@df.com']] type(name)
output:- list
array(name)
output:- NameError: name 'array' is not defined

#Firstly,it’ll fail to execute because its a function which is undefined.Array is just a function which is a part of Module.Here,we have Module called ‘numpy’.

#So,we’ll need to load this module for further use.Every O.S has their own command of installing library.In Python,if you have to install any Library you’ll need to write “pip install numpy”, but first check your internet connectivity before installing.

#Run Python once again then write the code “import numpy”, it will run successfully.

import numpy as np 
name = [['abcd,' 'hi@nh.com'], ['bcde,' 'hj@hg.com'], ['cdef,' 'bd@df.com']](name)
np.array(name)
array([['abcd,hi@nh.com'],
       ['bcde,hj@hg.com'],
       ['cdef,bd@df.com']], //output//

#In array,it shows concised form;in list it’s very complex.Whatever operation you do in array will appear columnwise.

name = [['abcd,' 'hi@nh.com'], ['bcde,' 'hj@hg.com'], ['cdef,' 'bd@df.com']]
a = np.array(name)
type(a) 
numpy.ndarray    //output//

#if you have to print column 2 of 1st row.

a[0:2]
array([['abcd,hi@nh.com'],
       ['bcde,hj@hg.com']],    //output//

In Artificial Intelligence, we have concepts like Computer Vision where you can do editing like putting stickers in selfie cameras, image processing, and face recognition.

One thought on “Library in Python

Leave a comment