Table of Contents
Python Tutorial
Table of Contents
Python Tutorial
Python dictionary in Hindi
What is Python Function
Function एक reusable blocks of code है जिसका use किसी specific task को perform करने के लिए किया जाता है। जब भी हमे अपने program मे ऐसे block of code की जरूरत पड़ती है जिसका use पूरे program मे कई बार होने वाला होता है तो उस code का function बना लेते है जिससे हमे उस code को बार बार लिखने की जरूरत नहीं होती हम बस उस function को call करेंगे हमारा काम हो जाएगा ।
How to Create Function
Def: Def keyword का use करके हम function define करते है,
Function name: किसी function को identify करने के लिए उसका एक unique name होता है जिसे हम function name कहते है ।
Function Body: इसमे function का वो code होता है जो किसी specific task perform करता है।
SYNTEX
Scope in Function
किसी variable को program में कहा तक access किया जा सकता है उसे ही scope उस variable का scope कहते है। Python में mainly 2 types के scope होते है-
Local Scope and Local Variable
अगर हम function के अंदर कोई variable बनाते है तो उसका use सिर्फ उसी function मे ही हो सकता है इसे ही local scope कहा जाता है, और ऐसे variables को local variable कहते कहते है।
Global Scope and Global Variable
ऐसे variables जो function body या किसी भी block के बाहर बनाते है उन्हे global variables कहा जाता है, इन variables को पूरे program मे कही भी use किया जा सकता है, और उस variable के scope को global scope कहेंगे।
Global Keyword
अगर हम चाहते है कि function के अंदर जो variable है उसका use कही भी कर सके तो उसके लिए global keyword का use करना होगा
Function Return
जब हम कोई function create करते है तो वो by default “none” return करता है, but अगर हम function से किसी value को return करना चाहते है तो return keyword का use करके एक या एक से अधिक values को return करा सकते है। function जो भी value return करेगा वो function calling के जगह पर आ जाएगा।
Note : जब function के अंदर का code चलता हो तो return मिलते है function का execution complete हो जाता है अगर हमने function body में return line के नीचे कोई code लिखा है तो वो execute नहीं होगा, इसलिए return को हमेशा last में लिखा जाता है but किसी specific condition पर हम return को बीच में भी use करते है।
Aliasing Function
Aliasing का मतलब होता है किसी function को दो अलग-अलग नाम से use करना ऐसा हम तब करते है जब किसी function नाम hard होता है तो हम एक simple नाम में उसे बदल देते है। aliasing करने के लिए हमे बस एक variable को create करना है और उसमे function name को assign कर देना अब हम उस variable को as a function use कर सके है।
Pass Statement
अगर हम function को define करके उसके function body मे कोई code न लिखे तो यह error देगा । error से बचने के लिए हम pass का use करते है.
SYNTEX
उम्मीद करते है कि आपको Python Function अच्छे समझ मे आ गया होगा । अपने learning को continue रखने के लिए next button पर click करे,
- All Posts
- Artificial Intelligence
- Computer Fundamentals
- Computer Networks
- Data Analytics
- Data Science
- DBMS
- Deep Learning
- Digital Electronics
- DSA with Python
- Excel
- Exercise
- Git & Github
- Machine Learning
- Matplotlib
- Natural Language Processing
- NumPy
- Operating System
- Pandas-s
- Power BI
- Python Tutorial
- Scikit-learn
- Seaborn
- SQL & MySQL

Table of Contents All Chapters 1. Personal Area Network 2. Local Area Network 3. Campus Area Network 4. Metropolitan Area...

Table of Contents All Chapters 1. Data Communication 2. Types of Data Communication 2.1. Simplex 2.2....

Table of Contents All Chapters 1. Special Logic Gate 2. XOR Gate 2.1. XOR Gate Truth Table 3....

Table of Contents All Chapters 1. Universal Logic Gates 2. NOR Gate 2.1. NOR Gate Truth Table 3....

Table of Contents All Chapters 1. Logic Gate 2. AND Gate 2.1. AND Gate Truth Table 3. OR...

Table of Contents All Chapters 1. Simplification 2. Simplification using Boolean Algebra Theorems 3. Simplification using K-map Digital Electronics...

Table of Contents All Chapters 1. Identity Laws 2. Null Laws 3. Domination Laws 4. Idempotent Laws 5. Complement Laws...