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 →

First Class Function in Python | Functions को Variable में कैसे Store करें? | Python Hindi

Python First Class Function

Python में Functions को सिर्फ code execute करने के लिए ही नहीं, बल्कि values की तरह भी treat किया जा सकता है। इसी property को First Class Function कहा जाता है।

इसका मतलब है कि Function को variable में store किया जा सकता है, दूसरे function में argument की तरह pass किया जा सकता है, और किसी function से return भी किया जा सकता है — बिल्कुल किसी number या string की तरह।

अगर आपने अभी Functions Basics नहीं पढ़ा है, तो पहले Python Functions Basics in Hindi पढ़ें। Examples खुद run करने के लिए हमारा Online Python Editor & Compiler use कर सकते हैं।

🎥 Video में समझें

First Class Function क्या है?

Python में Functions First Class Objects होते हैं। इसका मतलब है:

  • Function को किसी variable में store किया जा सकता है
  • Function को दूसरे function में argument की तरह pass किया जा सकता है
  • Function को किसी function से return किया जा सकता है
  • Function को list, dictionary जैसे data structures में भी रखा जा सकता है
सरल भाषा में — Python में Function एक normal value की तरह ही behave करता है।

Function को Variable में Store करना

Python में function को उसी तरह variable में assign किया जा सकता है जैसे किसी number या string को assign करते हैं।

Example
def greet(): print("Hello Python!") my_function = greet

ध्यान दें — यहाँ greet() नहीं लिखा, सिर्फ greet लिखा है। () लगाने से function turant execute हो जाता, लेकिन हमें उसे सिर्फ refer करना है।

Try it Yourself »

Variable के जरिए Function को Call करना

अब जिस variable में function store किया गया है, उसी से function को call किया जा सकता है।

Example
def greet(): print("Hello Python!") my_function = greet my_function()

Output:

Hello Python!

my_function() लिखने पर वही code execute होता है जो greet() के अंदर है, क्योंकि my_function उसी function को refer कर रहा है।

Try it Yourself »

function और function() में Difference

यह beginners के लिए सबसे common confusion है।

Syntaxमतलब
greetFunction object को refer करना (call नहीं हो रहा)
greet()Function को execute करना
❌ गलत
my_function = greet()

यह greet() को तुरंत execute कर देगा और उसका result (यहाँ None) my_function में store हो जाएगा — function खुद store नहीं होगा।

✅ सही
my_function = greet

Function को दूसरे Function में Argument की तरह Pass करना

Function को किसी दूसरे function में parameter की तरह भी भेजा जा सकता है।

Example
def greet(): print("Hello Python!") def execute_function(func): func() execute_function(greet)

Output:

Hello Python!

execute_function(greet) में greet function को argument की तरह pass किया गया, और execute_function() के अंदर func() लिखकर उसे call किया गया।

Try it Yourself »

Multiple Functions को Pass करना

Example
def morning(): print("Good Morning!") def evening(): print("Good Evening!") def execute(func): func() execute(morning) execute(evening)

Output:

Good Morning! Good Evening!

execute() function को पहले से नहीं पता कि कौन सा function मिलेगा — जो भी function argument में दिया जाएगा, वही execute होगा। यही First Class Function की असली power है।

Try it Yourself »

Function को Return करना

Python में एक function दूसरे function को return भी कर सकता है।

Example
def greet(): print("Hello Python!") def get_function(): return greet my_function = get_function() my_function()

Output:

Hello Python!

get_function() ने greet function को return किया, जिसे my_function में store करके फिर call किया गया।

Try it Yourself »
Note: return greet और return greet() एक जैसे नहीं हैं। पहला function को return करता है, दूसरा function को execute करके उसका result return करता है।

Function और Function Call में Difference

एक बार फिर इस difference को clearly समझते हैं, क्योंकि यह पूरे concept की नींव है।

Example
def show(): print("Function Called") # Function को refer करना reference = show # Function को call करना show()

Output:

Function Called

reference = show लाइन से कुछ print नहीं होता, क्योंकि यहाँ सिर्फ function को refer किया गया है। Output सिर्फ show() से आता है, जहाँ function actually call हुआ।

Try it Yourself »

Practical Example — Calculator

First Class Function की power को एक practical calculator example से समझते हैं।

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

Output:

15 5

यहाँ add और subtract दोनों functions को values की तरह calculate() में pass किया गया — यही First Class Function का practical फायदा है।

Try it Yourself »

VS Code में Live Coding

अगर आप इसे VS Code में खुद try करना चाहते हैं, तो एक नई file first_class.py बनाइए और यह code लिखिए:

first_class.py
def greet(): print("Hello Python!") def execute(func): func() my_function = greet my_function() execute(greet)

File save करके VS Code के Terminal में इसे run कीजिए।

Terminal में Actual Output

ऊपर वाली file को terminal में run करने पर output कुछ इस तरह दिखेगा:

$ python first_class.py Hello Python! Hello Python!

दोनों बार "Hello Python!" print हुआ — पहली बार my_function() से, और दूसरी बार execute(greet) के अंदर func() call होने से।

Common Mistakes

❌ Function को store करते समय () लगा देना
my_function = greet()

यह function को refer करने की जगह उसे तुरंत execute कर देगा।

✅ सही तरीका
my_function = greet
❌ Function को argument की तरह pass करते समय call कर देना
execute(greet())

greet() पहले ही execute हो जाएगा और उसका result execute() को मिलेगा — function खुद pass नहीं होगा।

✅ सही तरीका
execute(greet)
❌ return greet और return greet() को एक समझना
return greet # function को return करता है return greet() # function execute करके result return करता है

Quick Example — सब कुछ एक साथ

Example
def greet(): print("Hello Python!") def execute(func): func() def get_function(): return greet # Store में my_function = greet my_function() # Argument की तरह execute(greet) # Return से returned_function = get_function() returned_function()

Output:

Hello Python! Hello Python! Hello Python!
Try it Yourself »

Exercise ?

Function को बिना execute किए किसी variable में store करने के लिए क्या लिखा जाता है?

variable = function_name()
variable = function_name
variable = call(function_name)

Final Coding Challenge

अब खुद अपने Online Python Editor या VS Code में यह challenge solve कीजिए:

  1. एक square(n) function बनाइए जो किसी number का square return करे।
  2. एक cube(n) function बनाइए जो किसी number का cube return करे।
  3. एक apply(func, value) function बनाइए जो दिया गया function किसी value पर apply करे और result return करे।
  4. square और cube दोनों को apply() में pass करके result print कीजिए।
  5. एक choose_function(name) function बनाइए जो "square" या "cube" नाम के आधार पर सही function return करे।

Quick Revision

Conceptमतलब
First Class FunctionFunction को value की तरह treat करना
Function Storevariable = function_name
Function Callfunction_name()
Function as Argumentexecute(function_name)
Function Returnreturn function_name

FAQ

Python में First Class Function क्या है?

First Class Function वह property है जिसमें function को value की तरह treat किया जा सकता है — यानी variable में store, argument की तरह pass, और return किया जा सकता है।

function और function() में क्या फर्क है?

function सिर्फ function object को refer करता है, जबकि function() उसे execute करता है।

क्या हर Python function First Class Function होता है?

हाँ। Python में हर function by default एक first-class object होता है — इसके लिए कोई special syntax नहीं चाहिए।

Function को variable में store करने का फायदा क्या है?

इससे function को dynamically चुना जा सकता है, दूसरे functions को pass किया जा सकता है, और code ज्यादा flexible और reusable बनता है।

Summary

Python में Function एक value है — इसे store करो, pass करो, या return करो।

इस article में आपने सीखा कि First Class Function क्या होता है, function को variable में कैसे store करें, variable से function कैसे call करें, function को argument की तरह कैसे pass करें, function को कैसे return करें, और function व function() में क्या difference है।

यह concept Python के आगे के advanced topics — जैसे Lambda Function, Decorators, और Higher-Order Functions — को समझने की नींव है। अब ऊपर दिया गया coding challenge खुद VS Code या Online Editor में solve करें।

Related Articles

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