Ticker

6/recent/ticker-posts

Advertisement

Python Modules and library in hindi

    Python Modules in hindi
    Python Modules in hindi

     Python Modules in hindi : Python में Modules एक files होता  हैं,  जिसमें अलग-अलग प्रकार के function और, Variables, जिसे हम     पुनः प्रयोग कर सकते हैं Python modules in hindi किसी दूसरे प्रोग्राम  के coding में किया जाता है,

     इस Module को हम python Script File व Python Program File कहा जाता है जब  जब किसी Interactive Prompt  की सबसे बड़ी समस्या यह है कि हम चाहे किसी प्रोग्राम को एक लाइन का code  हो या  एक से अधिक 

    लाइन  यह हमारे codes  को किसी तरह से Save  नहीं रखता है ताकि हम उसे पुन: प्रयोग कर सकें! इसी समस्या को दूर करने के लिए हमें हमारे प्रोग्राम में codes  को एक Separate File में   लिखा होता है इस फाइल को Module  कहते हैं!

    Example:

    def add(a, b):

        return a + b

    Reloading Module in Python : Python में Module फाइल  को अपने प्रोग्राम के अंदर load  करने के लिए import Statement  से load   करते हैं,   अगर आप सी लैंग्वेज जानती है तू  आप पढ़े होंगे कि सबसे पहले#include

    <stdio.h> ऊपर लिखा जाता है इसी प्रकार से Import Statement  को  सबसे ऊपर लिखा जाता है. !!


    Syntax for import Statement

    import module_name1,

    Example:

    import math

    print(3+5)


    Output: 8


    Note.Python में दो प्रकार के Modules होते है |


    1.In-built Modules

    2.User-Defined Modules

    1.In built Modules :In built Module उसे कहा जाता है जो Python software download  कर केsoftware  Install    करते समय Install या   हम कह सकते हैं कि In built Module  पहले से बना होता है Python में 350+Modules होता है ! 

    Example :math,random,sqr,ये Modules  अलग-अलग काम करने के लिए  बने होते हैं  math module  में mathematics से related कुछ functions होते है जैसे कि, sin(), cos() और sqrt() e.t.c|

    Note : Python  में सभी In built Modules  देखने के लिए code  को लिखना पड़ता है ||


    Code: help("modules ")


    2. User-Defined Modules :Modules Creating  करने के लिए सबसे पहले  नई file open करते हैं और आप जो Module  का नाम देना चाहते हैं Module-name. Py से Save कर देते हैं! और हमेशाModule string variable _name होता हैं


    Example:Example:  यहां पर हम एक नई फाइल open करते हैं और Module  का नाम calc. py  Save कर देते हैं  और यहां पर  हमारा calc  एक नई Module  का नाम है

     Python Modules and  library   in hindi इसके बाद हमें def function  लिखा जाता है  function  में  अपने हिसाब से लिख सकते है  जैसे कि आप उदाहरण देख रहे हैं  हमdef  के साथ add, sub, multi,div function  बनाए हैं 

    Code Example:

    def  add(a,b):

        return a+b

    def sub(a,b):

        return a-b

    def multi (a,b):

        return a*b

    def div(a,b):

        return a/b


    Note: import calc

    x=calc.add(2,3)

    print("sum of to two no =",x)

     

    import calc 


    y = calc.sub(5,6)

    print("sub of to two no =",y)

    import calc 

    y = calc.multi(5,6)

    print("multi of to two no =",y)

    import calc 

    y = calc.div(5,6)

    print("div of to two no =",y)


    From_import Statement :From  का प्रयोग कहां किया जाता हैPython modules in hindi  जहां पर हम अपने प्रोग्राम में बिना module name  से  class  को access  हो तो   या हम एक module name   में  एक से अधिक

     def function  बनाए हो तो  अगर उसमें से हमें केवल एक या दो function को  अपने प्रोग्राम में  access  करना चाहते हैं तो वहां परfrom-import Statement  प्रयोग किया जाता हैं ||

    Syntax :

    from module_name import name1, name2,.., name2

    Example :  हमारे calc module   में  4function  बना है  इसमें हमें केवल दो function को access  करने के लिए  from-import Statement   प्रयोग किया गया हैं !!


    Code Example:

    from calc import add,mult

    x= add(3,4)

    print("sum of two no = ",)

    y=multi(5,5)

    print("multi of two no = ",y)

    Output: 7

    Output: 25

    Python library : पाइथन लाइब्रेरी  पैकेज पैकेज और function और Module से मिलकर बना होता है और पाइथन लाइब्रेरी बहुत बड़ी  है 

     पाइथन लाइब्रेरी  अनेकों तरह के  कार्यों के लिए प्रयोग किया जाता है Example : ग्राफिकल यूजर इंटरफेस (GUI ) बनाने के लिएऔर  data science, machine learning, deep learning, video frames  के लिए प्रयोग किया जाता है ||

    Python में  कुछ important लाइब्रेरी :

    1.NumPy

    2. Pnadas

    3. Matplotlib

     लाइफ साइकल

    1.Python में numpy  लाइब्रेरी का प्रयोग : Python में numpy  लाइब्रेरी का प्रयोग : न्यूमेरिकल और scientic computing  के लिए प्रयोग किया जाता है,  numpy  की सहायता से हम पाइथन प्रोग्राम में  multi dimensional array  होता है

     जिसमें हम  row,Column   कर सकते हैं  जबकि java, c में multi dimensional  नहीं होता है उसमें सिर्फ एक ही array  होता हैं ! इस multi dimensional  के साथ कुछ method होता हैं उस method  का प्रयोग करके multi dimensional arrays   को process  कम सकते हैं|

    Creating NumPy Array : करने के लिए सबसे पहले हमें numpy  लाइब्रेरी को load   करना होता है,  और यहां पर हम import numpy as np  लिखने के बाद उसने एक लिस्ट लिए और उसमें([12,30,23,24,56] )number  पास कर देते हैं और हम इस लिस्ट को np.array method  पास किए हैं  ||

    DHCP IN HINDI 

    Example: 

    Single dimensional Array :

    import numpy as np

    n1=np.array([12,30,23,24,56])

    print(n1)

    Output: [12 30 23 24 56]

     type(n1) 

    Output: numpy.ndarray

    Multi dimensiona Array :

    import numpy as np 

    n2=np.array([[1,2,3,4],[1,6,8,9]]

    print(n2)

    Output : 

    [[1 2 3 4]

     [1 6 8 9]]

    Initializing NumPy Array :

    Initializing Numpy array with zeros :


    Example 1:

    import numpy as np 

    n1 = np.zeros((1,2))

    print(n1)

    Output: [[0. 0.]]


    Example: 2

    import numpy as np 

    n1 = np.zeros((5,5))

    print(n1)

    Output :

    [[0. 0. 0. 0. 0.]

     [0. 0. 0. 0. 0.]

     [0. 0. 0. 0. 0.]

     [0. 0. 0. 0. 0.]

     [0. 0. 0. 0. 0.]]

    Initializing Numpy array with same number: 

    Code E xample :

    import numpy as np 

    n1 = np.full((5,5),10)

    print(n1)

    Output:

    [[10 10 10 10 10]

     [10 10 10 10 10]

     [10 10 10 10 10]

     [10 10 10 10 10]

     [10 10 10 10 10]]


    Initializing Numpy array within a range:

    Code Example : 

    import numpy as np 

    n1 = np.arange(12,16)

    print(n1)

    Output : [12 13 14 15]

    NumPy Array Mathematics :


    1. Addition of Numpy Array

    Code Example:

    import numpy as np

    n1=np.array([12,30,23])

    n2=np.array([12,30,23])

    np.sum(n1+n2)

    Output: 130


    Example 2:

    import numpy as np

    n1=np.array([12,30,23,24,56])

    n1=n1+1

    print(n1)

    Output: [13 31 24 25 57]

    2.Subtraction of Numpy Array

    Code Example:

    import numpy as np

    n1=np.array([12,30,23,24,56])

    n1=n1-1

    print(n1)


    Output: [11 29 22 23 55]

    3.Multiplication of Numpy Array

    Code   Example:

    import numpy as np

    n1=np.array([12,30,23,24,56])

    n1=n1*2

    print(n1)

    Output: [ 24  60  46  48 112]

    4.Division of Numpy Array :

    import numpy as np

    n1=np.array([12,30,23,24,56])

    n1=n1/2

    print(n1)

    Output: [ 6.  15.  11.5 12.  28. ]

    Numpy Math Function : 

    1. Mean Function :

    Code Example :

    import numpy as np

    n1=np.array([12,30,23,24,56])

    np.mean(n1)

    Output: 29.0

    2.Standard Deviation Function :

    Code Example :

    import numpy as np

    n1=np.array([12,30,23,24,56])

    np.std(n1)

    Output: 14.696938456699069 


    3. Medin Function:

    import numpy as np

    n1=np.array([12,30,23,24,56])

    np.median(n1)

    Output: 24.0

    2.Python में Pandas  लाइब्रेरी का प्रयोग : Python में Pandas  लाइब्रेरी का प्रयोग data manipulationऔर  date analysis  के लिए प्रयोग होता है और यह एक core library है  जिस प्रकार से Numpy  हमें single array और multi dimensional array होता है 

    उसी प्रकार से Pandas  हमें  singleऔर mulit dimensional date structures  से होता है इसमें कुछ method  प्रयोग करके हम data का manipulation  करते हैंll

    Creating Pandas  :  करने के लिए सबसे पहले हमें Pandas  लाइब्रेरी को load   करना होता है,  और यहां पर हम import pandas as pd  लिखने के बाद उसने एक लिस्ट लिए और उसमें Series और  data frame  पास कर देते हैं और हम इस लिस्ट को pd.Series method  पास किए हैं ||

    Pandas Data Structures : दो प्रकार के होते  हैंll

    1.Sangle - dimensional
    2.Multi dimensional
    Pandas Series Object :  Sangle - dimensional को series object  कहां जाता हैll

     Example:

    import pandas as pd 

    s1=pd.Series([1,2,3,4,5])

    print(s1)

    Output:

    0    1
    1    2
    2    3
    3    4
    4    5
    dtype: int64

    type(s1)

    Output: pandas.core.series.Series
    Changing Index value :

    Code Example: 
    import pandas as pd 
    s1=pd.Series([1,2,3,4,5],index=['a','b','c','d','e'])
    print(s1)

    Output: 
    a    1
    b    2
    c    3
    d    4
    e    5
    dtype: int64

    Seriesमें Object Dictionary का प्रयोग :
    Code Example:

    import pandas as pd

    pd.Series({'a':10,'b':20,'c':30})

    Output:

    a    10
    b    20
    c    30
    dtype: int64


    ABOUT.नमस्कार दोस्तों आपको हमारे नए पोस्ट में स्वागत है  आपको इस पोस्ट में मिलेगा Python Programming in hindi full   कोर्स course  अगर आप Machine learning  data science deep learning  सीखना चाहते हैं तो 


    आप हमारे इस पोस्ट को फॉलो करो आपको इस पोस्ट को पढ़ने के लिए बहुत-बहुत धन्यवादl
















    एक टिप्पणी भेजें

    0 टिप्पणियाँ