Python Full Course In Hindi

Home About Us Contact Us Privacy Policy

Introduction To Modules


Python के अन्दर Modules एक File होती है | इस File के अन्दर python codes होते है | इस file के किसी code का अलग python file के अन्दर उपयोग किया जा सकता है | उपयोग करने के लिए import statement का उपयोग किया जाता है | Python के अन्दर Modules का उपयोग करना बहुत फायदेमंद है | Python के अन्दर Modules को तीन भाग मे devide किया गया है |
1.Built-In Modules
2.User Defin Module
3.Third Party Modules
4.Packages Modules

1.Built-in Modules


Built-in modules python के साथ में ही आते है | यानि की इनके उपयोग के लिए इन्हें Install करने की ज़रूरत नही होती है |
Examples
Math modules
date time module etc.

1. Math Module

math module एक Built-In module है | जिसका उपयोग mahtematical calculations के लिए किया जाता है | python मे math module के उपयोग के लिए math.sqrt(), math.log(),math.sin() etc. functions का उपयोग किया जाता है |
🐍 Syntax
import math print(math.factorial(8)) # factorial निकालने के लिए print(math.sqrt(25)) # Square root के लिए print(math.log(29)) # natural logaithm के लिए print(math.floor(-7.4))
Output
40320
5.0
3.367295829986474
-8

2. Date Time Module

latest date पता करने के लिए Datetime module का उपयोग किया जाता है | python मे Date time module के लिए q.strftime("%b"),q.strftime("%B"),q.strftime("%m"), q.strftime("%Y"),q.strftime("%M") etc. functions का उपयोग किया जाता है |

🐍 Syntax
import datetime q = datetime.datetime.now() n = q.strftime("%b") print(n) q = datetime.datetime.now() n = q.strftime("%B") print(n) q = datetime.datetime.now() n = q.strftime("%m") print(n) q = datetime.datetime.now() n=q.strftime("%y") print(n) q = datetime.datetime.now() n=q.strftime("%M") print(n)
Output
Oct
October
10
25
39
इसी तरह बहुत सारे Built-In Modules होते है |

2. User Defin Modules

user defin modules वे modules होते है | जिनको user अपने काम को सरल बनाने हेतु create करता है | यानि इन modules को user के द्वारा बनाया जाता है | ये module python की एक file होती है | जिसके अन्दर user functions , classes , varriables etc. create करता है | और इस file से इन functions varriables classes etc. को किसी और file के अन्दर import करता है |

How To create User Defin Modules

🐍 sum.py
# sum.py def addition(a , b) : return a + b

sum.py से sum functions को import करने के लिए

🐍 import.py
# import.py import sum res = sum.addition(4,8) print(res)
Output
12

3. Third-Party Modules

ये वे modules होते है | जो न तो python के साथ में पहले से install हुए आते है | और न ही user के द्वारा बनाया जाते है | बल्कि ये modules किसी बाहरी organization या किसी बाहरी developer के द्वारा बनाऐ जाते है | इसलिए इन modules का use करने के लिए इन्हें अलग से install करना होता है | इन modules को install करने के लिए pip command का use किया जाता है |

For Example

🐍 Syntax
pip install module-name # For Example pip install emoji

How To Use Of emoji module

🐍 Syntax
import emoji print(emoji.emojize("I love python : snake:"))
इसी तरह बहुत सारे Third-Party Modules होते है |