Types of Functions in Python
Python में Functions मुख्य रूप से दो प्रकार के होते हैं:
Built-in Functions
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
Explanation:
def — Function Define करने के लिए उपयोग होता है।
function_name — Function का नाम होता है।
statements — वे Statements होते हैं जिन्हें Function के Call होने पर Execute किया जाता है।
Example of User-Defined Function (उदाहरण)
Output:
Hello, World! Explanation of the Example (उदाहरण की व्याख्या)
def — Function को Define करने के लिए उपयोग होता है।
greet — Function का नाम है।
print("Hello, World!") — Screen पर Message Display करता है।
greet() — Function को Call करता है, जिससे Function के अंदर लिखे Statements Execute होते हैं।