Seedha content par jao
🤖 Python Hindi Bot
Namaste! Main Python Hindi Bot hoon 🐍
Python ya AI se related kuch bhi type karke pucho, ya neeche se quick sawaal chuno.
WhatsApp

Stay Connected with PythonHindii

Join our WhatsApp Community to get the latest Python tutorials, coding tips, interview questions, project updates, and learning resources directly on your phone.

Join WhatsApp Community
Python Hindi Logo
Python in Hindi | Programming Education
Python programming tutorial in Hindi banner Python code learning illustration Hindi Python student coding illustration Python data code pattern background

Python Tutorial in HindiiLearn Python Programming for Free

Learn Python from Beginner to Advanced in simple Hindi.

print("Namaste Python!")
# Variable banana
naam = "Ankit"
umar = 25
 
for i in range(3):
  print("Sikho!")
 
# Output:
Sikho! Sikho! Sikho!

Why Students Learn Here

📚

Structured Tutorials

Beginner se Advanced tak step-by-step organized lessons.

💻

Practical Code

Real examples aur hands-on code jo actually samajh aaye.

🧠

Python + AI Path

Ek clear roadmap jo Python se AI tak le jaata hai.

🚀

Projects & Career

Portfolio-ready projects aur interview preparation.

Ye Kaise Kaam Karta Hai

Hindi mein Python, AI aur Data Skills seekhne ka sabse simple tareeka.

📘

Seekhein

Beginner se Advanced tak, best curated tutorials aur guides Hindi mein.

💻

Practice Karein

Real code examples aur mini-projects ke through hands-on practice karein.

💬

Judein

WhatsApp community se judkar apne doubts clear karein, akele nahi seekhenge.

Python to AI Learning Roadmap

Step-by-step learning path from Python basics to AI, Data Science and career-ready projects.

1
🐍

Python Basics

Introduction, Variables, Data Types, Operators, Input & Output, Conditions, Loops, Functions

Start Python →
2
💻

Python Intermediate

Lists, Tuples, Sets, Dictionaries, Strings, Functions, Modules, File Handling, Exception Handling

Continue Python →
3
⚙️

Advanced Python

OOP, Iterators, Generators, Decorators, Regular Expressions, APIs, Automation, Virtual Environments

Learn Advanced Python →
4
🗄️

SQL & Databases

SQL Basics, MySQL, SELECT, INSERT, UPDATE, DELETE, JOIN, GROUP BY, Database Projects

Learn SQL →
5
📊

Data Analytics

NumPy, Pandas, Data Cleaning, Data Visualization, Matplotlib, Exploratory Data Analysis

Learn Data Analytics →
6
🤖

Machine Learning

ML Basics, Supervised & Unsupervised Learning, Regression, Classification, Model Evaluation, Scikit-learn

Learn Machine Learning →
7
🧠

Artificial Intelligence

AI Fundamentals, Generative AI, AI Tools, Prompt Engineering, LLM Concepts, AI Automation

Explore AI →
8
🚀

Projects & Career

Python Projects, AI Projects, Data Projects, Portfolio, GitHub, Interview Preparation, Career Roadmap

Build Your Career →

Python Functions Basics in Hindi — Function क्या है और कैसे बनाएं? | Python Hindi Tutorial

Python Functions in Hindi tutorial thumbnail with Python logo and coding background

Python Functions in Hindi

Python सीखते समय शुरुआत में हम एक-एक करके code लिखते हैं। लेकिन जैसे-जैसे program बड़ा होता जाता है, एक ही काम के लिए बार-बार वही code लिखना पड़ सकता है। यहीं से Python Functions काम आते हैं।

Function code के किसी specific काम को एक जगह define करने का तरीका है, जिसे जरूरत पड़ने पर बार-बार call किया जा सकता है।

अगर आप Python बिल्कुल शुरुआत से सीख रहे हैं, तो पहले हमारा Python Tutorial in Hindi पूरा learning roadmap देख सकते हैं। Examples खुद run करने के लिए हमारा Online Python Editor & Compiler use कर सकते हैं।

Function क्या होता है?

Python में Function एक reusable block of code होता है, जिसे किसी specific task को perform करने के लिए बनाया जाता है।

एक बार code लिखो और जरूरत पड़ने पर उसे बार-बार इस्तेमाल करो।
Example — बिना function के

Message को पांच बार print करना है:

print("Hello Python") print("Hello Python") print("Hello Python") print("Hello Python") print("Hello Python")
Example — function के साथ

एक reusable block बनाकर जरूरत पड़ने पर call करो:

def hello(): print("Hello Python") hello()

Output:

Hello Python
Try it Yourself »

Function की जरूरत क्यों होती है?

Functions का सबसे बड़ा फायदा है कि वे program को reusable, organized और easy to maintain बनाते हैं:

  • Code को बार-बार लिखने से बचाते हैं — एक ही logic को कई जगह इस्तेमाल किया जा सकता है
  • Program को छोटे हिस्सों में divide करते हैं — बड़ा code समझना आसान हो जाता है
  • Readability बढ़ाते हैं — function के नाम से पता चलता है वो क्या करता है
  • Debugging आसान बनाते हैं — किसी एक task का function अलग से check हो सकता है
  • Code reuse करने देते हैं — एक function को कई बार call कर सकते हैं

Function का Syntax

Python में function बनाने के लिए def keyword इस्तेमाल होता है।

Syntax
def function_name(): # function का code
  • def → function define करने का keyword
  • function_name → function का नाम
  • () → parameters लिखने के लिए
  • : → definition के बाद colon जरूरी है
  • Indentation के अंदर लिखा code → function का body

अपना पहला Function बनाइए

Example
def greet(): print("Namaste Python!") greet()

Output:

Namaste Python!
Try it Yourself »

Function Define करना vs Call करना

जब हम function बनाते हैं, उसे define करना कहते हैं। जब हम उसे चलाते हैं, उसे call करना कहते हैं।

Example
def greet(): print("Namaste Python!") # define greet() # call
Try it Yourself »
Note: अगर आप function को call नहीं करेंगे, तो उसके अंदर लिखा code अपने-आप execute नहीं होगा।

Function को Multiple Times Call करना

Function की सबसे useful बात यही है कि हम उसे कई बार call कर सकते हैं।

Example
def greet(): print("Namaste Python!") greet() greet() greet()

Output:

Namaste Python! Namaste Python! Namaste Python!
Try it Yourself »

Function में Parameters

कई बार function को बाहर से information देनी होती है। इसके लिए parameter इस्तेमाल किया जाता है।

Example
def greet(name): print("Namaste", name) greet("Ankit") greet("Rahul") greet("Aman")

Output:

Namaste Ankit Namaste Rahul Namaste Aman
Try it Yourself »

Parameter vs Argument

Beginners अक्सर parameter और argument को एक ही समझ लेते हैं, लेकिन दोनों में छोटा सा difference है:

Termकब इस्तेमाल होता हैExample
ParameterFunction define करते समयdef greet(name):
ArgumentFunction call करते समय दी गई valuegreet("Ankit")

Multiple Parameters

एक function में एक से ज्यादा parameters भी हो सकते हैं।

Example
def introduce(name, age): print("Name:", name) print("Age:", age) introduce("Ankit", 25)

Output:

Name: Ankit Age: 25
Try it Yourself »

Function से Calculation करना

Functions सिर्फ messages print करने के लिए नहीं होते — इनके अंदर calculations भी हो सकती हैं।

Example
def add(a, b): print(a + b) add(10, 20) def multiply(a, b): print(a * b) multiply(5, 4)

Output:

30 20
Try it Yourself »

Operators के बारे में detail में जानने के लिए Python Operators in Hindi पढ़ सकते हैं।

Return Statement

कई बार हमें function के अंदर result calculate करके उसे बाहर वापस देना होता है। इसके लिए return इस्तेमाल किया जाता है।

Example
def add(a, b): return a + b result = add(10, 20) print(result)

Output:

30
Try it Yourself »

print() vs return

यह beginners के लिए बहुत important difference है। print() सिर्फ result को screen पर दिखाता है, जबकि return value को function से बाहर वापस देता है और उसे आगे इस्तेमाल किया जा सकता है।

Example — return की value आगे इस्तेमाल करना
def add(a, b): return a + b result = add(10, 20) final_result = result * 2 print(final_result)

Output:

60
Try it Yourself »
Statementक्या करता है
print()Result को screen पर दिखाता है
returnValue को function से बाहर वापस देता है, जिसे आगे इस्तेमाल किया जा सकता है

Real Example — Student का Total Marks

Example
def total_marks(math, science, english): return math + science + english total = total_marks(80, 75, 90) print("Total Marks:", total)

Output:

Total Marks: 245
Try it Yourself »

अलग-अलग students के लिए उसी function को reuse भी किया जा सकता है:

student1 = total_marks(80, 75, 90) student2 = total_marks(70, 85, 88) print(student1) print(student2)
Try it Yourself »

Positional Arguments

जब arguments को उसी order में दिया जाता है जिस order में parameters define किए गए हैं, तो उन्हें positional arguments कहा जाता है।

Example
def student(name, age): print("Name:", name) print("Age:", age) student("Ankit", 25)
Try it Yourself »

Keyword Arguments

Python में हम parameter का नाम लिखकर भी value दे सकते हैं — इसे keyword argument कहते हैं।

Example
def student(name, age): print("Name:", name) print("Age:", age) student(age=25, name="Ankit")

Output:

Name: Ankit Age: 25

Order बदलने पर भी सही result मिलता है, क्योंकि parameter के नाम explicitly दिए गए हैं।

Try it Yourself »

Default Parameter

अगर user कोई value provide न करे, तो function एक default value इस्तेमाल कर सकता है।

Example
def greet(name="Guest"): print("Hello", name) greet("Ankit") greet()

Output:

Hello Ankit Hello Guest
Try it Yourself »

Real-Life Example — Simple Calculator

Example
def add(a, b): return a + b def subtract(a, b): return a - b def multiply(a, b): return a * b print(add(10, 5)) print(subtract(10, 5)) print(multiply(10, 5))

Output:

15 5 50
Try it Yourself »

Function के अंदर Variable

Function के अंदर बनाए गए variables सामान्यतः उसी function के local scope में होते हैं।

Example
def show_name(): name = "Ankit" print(name) show_name()

Output:

Ankit
Try it Yourself »
Note: Global और Local Variables का detail चैप्टर हमारे Python course में आगे अलग से कवर किया गया है।

Function में Indentation

Python में indentation बहुत important है — function के अंदर का code proper indentation के साथ होना चाहिए।

सही तरीका
def greet(): print("Hello")
गलत तरीका
def greet(): print("Hello")

अगर आपने अभी Python indentation और basic syntax सीखा है, तो पहले Python Tutorial in Hindi के शुरुआती chapters को एक बार revise कर सकते हैं।

Common Mistakes

❌ def के बाद function name भूल जाना
def(): print("Hello")
✅ सही तरीका
def greet(): print("Hello")
❌ Colon : भूल जाना
def greet() print("Hello")
✅ सही तरीका
def greet(): print("Hello")
❌ Function call नहीं करना
def greet(): print("Hello") # "Hello" print नहीं होगा
✅ सही तरीका
def greet(): print("Hello") greet()
❌ Parameter की संख्या गलत देना
def add(a, b): return a + b add(10) # Error: दूसरा argument missing
✅ सही तरीका
add(10, 20)
❌ print() और return को confuse करना

यह समझना जरूरी है कि print() सिर्फ output दिखाता है, जबकि return value को function से वापस देता है जो आगे इस्तेमाल हो सकती है।

पहले सीखे Concepts का Connection

Functions को समझने के लिए आपके पहले के Python concepts भी काम आते हैं:

  • Variables → values store करने के लिए
  • Data Types → values के type को समझने के लिए
  • Operators → calculations और comparisons के लिए
  • Input → user से data लेने के लिए
  • If/Else → conditions के आधार पर decision लेने के लिए
  • Loops → repetitive tasks के लिए
  • Functions → code को reusable बनाने के लिए

आप पहले Python Variables, Python Data Types और Python Type Casting को भी revise कर सकते हैं। Conditional logic के लिए Python If Else in Hindi और repetition समझने के लिए Python For Loop in Hindi पढ़ें।

एक Complete Function Example

Example
def calculate_total(price, quantity): total = price * quantity return total price = 500 quantity = 3 result = calculate_total(price, quantity) print("Total Price:", result)

Output:

Total Price: 1500
Try it Yourself »

यहाँ def calculate_total(price, quantity): function define करता है, price * quantity total calculate करता है, return total result वापस देता है, और calculate_total(price, quantity) function को call करता है।

Exercise ?

return statement function में क्या करता है?

Value को screen पर print करता है
Value को function से बाहर वापस देता है
Function को call करता है

Practice करने का सही तरीका

Function सिर्फ syntax याद करने से अच्छी तरह नहीं आएगा। इन steps से practice करें:

  1. एक simple greeting function बनाएं
  2. दो numbers जोड़ने वाला function बनाएं
  3. दो numbers multiply करने वाला function बनाएं
  4. Student के तीन subjects के total का function बनाएं
  5. Rectangle का area calculate करने वाला function बनाएं
  6. किसी number का square return करने वाला function बनाएं
  7. Default parameter वाला greeting function बनाएं
  8. दो parameters वाला अपना कोई छोटा function बनाएं

Practice Questions

अब इन questions को खुद अपने Online Python Editor में solve करके देखें:

  1. एक function बनाइए जो "Hello Python" print करे।
  2. एक function बनाइए जो दो numbers लेकर उनका sum return करे।
  3. एक function बनाइए जो किसी number का square return करे।
  4. एक function बनाइए जो name और age लेकर दोनों को print करे।
  5. एक function बनाइए जो तीन subjects के marks लेकर total return करे।
  6. एक function बनाइए जिसमें name का default value "Guest" हो।
  7. एक function बनाइए जो किसी product की price और quantity लेकर total price return करे।

अभी क्या नहीं पढ़ना है?

Python Functions का पूरा topic काफी बड़ा है, इसलिए शुरुआत में सिर्फ basic concepts को मजबूत करना जरूरी है। इस chapter में हमने function definition, calling, parameters, arguments, multiple parameters, return, positional arguments, keyword arguments और default parameters समझे।

अभी इन advanced topics को जानबूझकर अलग रखा गया है — ये आगे के course chapters में समझाए जाएंगे:

  • *args
  • **kwargs
  • Recursion
  • Lambda Function
  • First Class Functions
  • Inner Functions
  • Decorators

Quick Revision

Conceptमतलब
defFunction बनाने के लिए
Function NameFunction की पहचान
ParameterFunction definition में input
ArgumentFunction call करते समय दी गई value
returnFunction से value वापस देना
Function CallFunction को execute करना
Default ParameterParameter की default value
Keyword ArgumentParameter name के साथ value देना

FAQ

Python Function क्या है?

Python Function code का एक reusable block है, जिसे किसी specific task को perform करने के लिए बनाया जाता है और जरूरत पड़ने पर बार-बार call किया जा सकता है।

Python में function कैसे बनाते हैं?

Python में function बनाने के लिए  Def keyword का इस्तेमाल किया जाता है:

def greet(): print("Hello")

Function को call कैसे करते हैं?

Function के नाम के बाद parentheses लगाकर उसे call किया जाता है: greet()

Parameter और Argument में क्या अंतर है?

Function define करते समय लिखी गई input variable को parameter कहते हैं, जबकि function call करते समय दी गई actual value को argument कहते हैं।

Python में return क्यों इस्तेमाल करते हैं?

return function से किसी value को बाहर वापस देने के लिए इस्तेमाल होता है। Returned value को variable में store करके आगे भी use किया जा सकता है।

क्या Python function को कई बार call कर सकते हैं?

हाँ। एक function को program में जरूरत के अनुसार कई बार call किया जा सकता है।

क्या Python function में multiple parameters हो सकते हैं?

हाँ। एक function में multiple parameters define किए जा सकते हैं:

def student(name, age): print(name, age)

Summary

Function = एक बार लिखो, बार-बार इस्तेमाल करो।

Python Functions programming के सबसे important concepts में से एक हैं। इनकी मदद से हम अपने code को छोटे और reusable parts में divide कर सकते हैं, जिससे code दोबारा लिखने की जरूरत कम होती है और बड़े programs को समझना व maintain करना आसान हो जाता है।

अब सबसे जरूरी काम है — इन concepts को खुद code करके practice करना। ऊपर दिए गए practice questions को अपने Online Python Editor में solve करें और फिर अगला chapter शुरू करें।

Related Articles

🧑‍💻 Python Coding Lab Python code likho, run karo aur practice karo — directly browser mein.