PYTHON PROGRAMMING SERIES • PART 2 Python Variables in Hindi

🐍 PYTHON PROGRAMMING SERIES • PART 2

Python Variables in Hindi

Variable क्या है? Python में Variables कैसे बनाएं?

🎯 आज का लक्ष्य
पिछली पोस्ट में हमने अपना पहला Python Program बनाया था। अब हम सीखेंगे कि Python में किसी information को store कैसे किया जाता है। इसके लिए हम Variables का इस्तेमाल करते हैं।

📦 Python Variable क्या है?

Variable एक ऐसा नाम है जिसका उपयोग program में किसी value को refer करने के लिए किया जाता है। आसान भाषा में समझें तो variable को आप एक ऐसे label की तरह समझ सकते हैं जिससे हम किसी data को पहचान सकते हैं।

उदाहरण के लिए अगर हमें किसी व्यक्ति का नाम store करना है, तो हम एक variable बना सकते हैं:

🐍 Python Code
name = "Rahul"

यहाँ name variable है और "Rahul" उसकी value है।

याद रखें: Python में variable बनाने के लिए किसी अलग command की जरूरत नहीं होती। आप सीधे variable का नाम लिखकर उसमें value assign कर सकते हैं।

✏️ Python में Variable कैसे बनाएं?

Variable बनाने का basic तरीका है:

Variable Syntax
variable_name = value

उदाहरण:

Examples
name = "Rahul" age = 20 city = "Jaipur"

इस example में हमने तीन variables बनाए:

  • name में "Rahul" store है।
  • age में 20 store है।
  • city में "Jaipur" store है।

🖨️ Variable की Value कैसे Print करें?

Variable बनाने के बाद हम उसकी value को print() function की मदद से screen पर दिखा सकते हैं।

Python Code
name = "Rahul" print(name)
📤 Output
Rahul

ध्यान दें कि print(name) में हमने name को quotes के अंदर नहीं लिखा है। इसलिए Python variable की stored value को output करेगा।

🔢 Number को Variable में Store करें

Variables में केवल text ही नहीं, बल्कि numbers भी store किए जा सकते हैं।

Number Variable
age = 20 print(age)
📤 Output
20

➕ Variables के साथ Calculation

Variables में रखे numbers के साथ mathematical calculations भी की जा सकती हैं।

Example
a = 10 b = 5 print(a + b)
📤 Output
15

इसी तरह subtraction, multiplication और division भी कर सकते हैं।

More Examples
a = 20 b = 5 print(a - b) print(a * b) print(a / b)
📤 Output
15 100 4.0

🔤 String Variable

जब हमें text store करना हो तो हम string variable बना सकते हैं। Text को quotes के अंदर लिखा जाता है।

String Example
name = "Amit" course = "Python Programming" print(name) print(course)
📤 Output
Amit Python Programming

🔢 एक साथ कई Variables बनाएं

एक program में आप जितने चाहें उतने variables बना सकते हैं।

Student Example
name = "Amit" age = 18 city = "Delhi" marks = 85 print(name) print(age) print(city) print(marks)
📤 Output
Amit 18 Delhi 85

🔄 Variable की Value बदल सकते हैं?

हाँ। Python में किसी variable को नई value assign करके उसकी value बदली जा सकती है।

Example
age = 18 print(age) age = 19 print(age)
📤 Output
18 19

पहले age की value 18 थी। बाद में हमने उसी variable में 19 assign कर दिया।

⚠️ Variable Name रखने के Rules

Python में variable का नाम रखते समय कुछ basic rules का ध्यान रखना चाहिए।

  • Variable का नाम letter या underscore _ से शुरू हो सकता है।
  • Variable के नाम में numbers इस्तेमाल किए जा सकते हैं, लेकिन नाम की शुरुआत number से नहीं होनी चाहिए।
  • Variable name में spaces नहीं होने चाहिए।
  • Python के reserved keywords को variable name के रूप में इस्तेमाल नहीं करना चाहिए।
  • Python में uppercase और lowercase अलग-अलग माने जाते हैं।

✅ सही Variable Names

Valid Examples
name = "Amit" age = 20 student_name = "Rahul" marks1 = 90 _my_variable = 100

❌ गलत Variable Names

Invalid Examples
1name = "Amit" student name = "Rahul"
⚠️ ध्यान दें: Variable name की शुरुआत number से नहीं करनी चाहिए और variable name के बीच space नहीं होना चाहिए।

🔠 Python Case-Sensitive है

Python में uppercase और lowercase letters को अलग माना जाता है।

Example
name = "Amit" Name = "Rahul" print(name) print(Name)
📤 Output
Amit Rahul

यहाँ name और Name दो अलग-अलग variables हैं।

🧠 Variable का Data Type कैसे देखें?

Python में किसी value का data type जानने के लिए type() function का इस्तेमाल किया जा सकता है। Data Types को हम अगली posts में विस्तार से सीखेंगे।

Example
name = "Amit" age = 20 print(type(name)) print(type(age))
📤 Output
<class 'str'> <class 'int'>

🪜 Step-by-Step Mini Project

अब हम एक छोटा सा student information program बनाएंगे।

🎓 Student Information Program
name = "Rahul" age = 18 city = "Jaipur" marks = 85 print("Name:", name) print("Age:", age) print("City:", city) print("Marks:", marks)
📤 Output
Name: Rahul Age: 18 City: Jaipur Marks: 85
🎉 Great! अब आपने variables का इस्तेमाल करके एक छोटा Python program बना लिया है।

🧪 आपकी Practice

🎓 Practice Challenge

खुद से एक Python program बनाइए जिसमें ये information variables में store हो:

  1. आपका नाम
  2. आपकी उम्र
  3. आपका शहर
  4. आपके marks

इसके बाद सभी values को print() function की मदद से screen पर दिखाइए।

🔥 Bonus Challenge: दो numbers को variables में store करके उनका addition और multiplication निकालिए।

🧠 Quick Quiz

Q1. Python में variable बनाने के लिए कौन-सा symbol इस्तेमाल किया जाता है?

A) ==
B) =
C) !=
D) =>

Answer: B) =

Q2. इनमें से कौन-सा सही variable है?

A) 1name = "Amit"
B) student name = "Amit"
C) student_name = "Amit"
D) student-name = "Amit"

Answer: C) student_name = "Amit"

Q3. Variable की value देखने के लिए कौन-सा function इस्तेमाल कर सकते हैं?

A) print()
B) show()
C) display()
D) output()

Answer: A) print()

📚 आज आपने क्या सीखा?

📦 Variable Variable क्या होता है और इसका उपयोग क्यों किया जाता है।
✏️ Assignment Variable में value कैसे assign करें।
🔤 String Text को variable में store करना।
🔢 Numbers Numbers को variables में store करके calculation करना।

❓ Frequently Asked Questions

Python Variable क्या है?

Variable एक नाम है जिसका उपयोग program में किसी value को refer करने के लिए किया जाता है।

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

Variable बनाने के लिए variable name के बाद = लगाकर value assign की जाती है। उदाहरण: age = 20

क्या Python variable की value बदली जा सकती है?

हाँ। किसी existing variable में नई value assign करके उसकी value बदली जा सकती है।

क्या variable name में space दे सकते हैं?

नहीं। Variable name में space की जगह underscore का इस्तेमाल किया जा सकता है। उदाहरण: student_name

🏷️ Topics Covered:
Python Variables Python in Hindi Python Tutorial Python Programming Python for Beginners Python Basics Learn Python in Hindi Python Variables in Hindi

टिप्पणियाँ

इस ब्लॉग से लोकप्रिय पोस्ट

Python से Simple Calculator कैसे बनाएं | Python Calculator Code in Hindi (CLI + GUI Tutorial)

How to Create a To-Do List using Python.

Learn Python in Hindi: अपना पहला Python Program बनाना सीखें | Python Tutorial Part 1