Important Notice:

Types of Functions in Python

Types of Functions in Python

24 views 1 min read

Types of Functions in Python

Python में Functions मुख्य रूप से दो प्रकार के होते हैं:

  1. Built-in Functions

  2. User-Defined Functions

1. Built-in Functions in Python (इन-बिल्ट फंक्शन्स)

 Python में Built-in Functions वे Predefined Functions होते हैं, जो Python में पहले से उपलब्ध होते हैं। इनका उपयोग किसी विशेष कार्य को पूरा करने के लिए किया जाता है। इन्हें उपयोग करने के लिए सामान्यतः स्वयं Function Define करने की आवश्यकता नहीं होती।

English Definition: Built-in Functions are predefined functions that are already available in Python. They are used to perform specific tasks without having to define them yourself.

Example:

print(), input(), len(), type(), int(), float(), str(), bool(), sum(), max(), min(), abs(), round(), sorted(), range(), pow(), enumerate(), zip(), any(), all()

2. User-Defined Functions in Python (यूज़र-डिफाइंड फंक्शन्स)

 Python में User-Defined Function वह Function होता है जिसे Programmer अपनी आवश्यकता के अनुसार स्वयं Define (बनाता) है। इसे def Keyword का उपयोग करके बनाया जाता है।

English Definition: A User-Defined Function is a function created by the programmer to perform a specific task. It is defined using the def keyword in Python.

Syntax 

def function_name():
    statements

Explanation:

  1. def — Function Define करने के लिए उपयोग होता है।

  2. function_name — Function का नाम होता है।

  3. statements — वे Statements होते हैं जिन्हें Function के Call होने पर Execute किया जाता है।

 Example of User-Defined Function (उदाहरण)

def greet():
    print("Hello, World!")

greet()

Output:

Hello, World!  Explanation of the Example (उदाहरण की व्याख्या)

  1. def — Function को Define करने के लिए उपयोग होता है।

  2. greet — Function का नाम है।

  3. print("Hello, World!") — Screen पर Message Display करता है।

  4. greet() — Function को Call करता है, जिससे Function के अंदर लिखे Statements Execute होते हैं।

Related Notes