Python Data Types क्या हैं?
Python में Data Types को आसान भाषा में समझें और int, float, string तथा boolean के साथ programming शुरू करें।
इस lesson में हम जानेंगे कि Data Type क्या होता है, Python में प्रमुख Data Types कौन-कौन से हैं और अलग-अलग प्रकार की values को कैसे पहचानते हैं।
🐍 Data Type क्या होता है?
Programming में अलग-अलग प्रकार की information को store किया जाता है। जैसे किसी व्यक्ति का नाम, उम्र, मोबाइल नंबर, अंक या कोई Yes/No value।
इन values के प्रकार को Data Type कहा जाता है।
⭐ Python के प्रमुख Data Types
Python में कई built-in Data Types होते हैं। Beginners के लिए सबसे महत्वपूर्ण Data Types हैं:
- int – पूर्ण संख्या
- float – दशमलव संख्या
- str – Text या String
- bool – True या False
- list – Values का collection
- tuple – Ordered collection
- dict – Key और Value का collection
- set – Unique values का collection
1️⃣ Integer — int
Integer का उपयोग पूर्ण संख्याओं के लिए किया जाता है। इसमें दशमलव नहीं होता।
age = 18
marks = 95
year = 2026
ऊपर दिए गए सभी Variables में Integer values हैं।
2️⃣ Float — float
Float का उपयोग दशमलव वाली संख्याओं के लिए किया जाता है।
price = 99.50
height = 5.8
percentage = 87.5
3️⃣ String — str
String का उपयोग Text को store करने के लिए किया जाता है। String को सामान्यतः single quotes या double quotes में लिखा जाता है।
name = "Rahul"
city = "Jaipur"
course = 'Python Programming'
String में letters, numbers और special characters भी हो सकते हैं, लेकिन quotes के अंदर लिखे होने के कारण वे Text माने जाते हैं।
4️⃣ Boolean — bool
Boolean Data Type में केवल दो मुख्य values होती हैं:
True
False
उदाहरण:
is_student = True
is_teacher = False
True और False का पहला अक्षर
Capital होता है।
🔍 Data Type कैसे पता करें?
Python में किसी Variable का Data Type पता करने के लिए type() function का उपयोग किया जाता है।
age = 18
name = "Rahul"
height = 5.8
student = True
print(type(age))
print(type(name))
print(type(height))
print(type(student))
Output:
<class 'int'>
<class 'str'>
<class 'float'>
<class 'bool'>
🧪 एक Complete Example
name = "Rahul"
age = 20
percentage = 85.5
is_student = True
print(name)
print(age)
print(percentage)
print(is_student)
print(type(name))
print(type(age))
print(type(percentage))
print(type(is_student))
📊 Data Types को एक नजर में समझें
| Data Type | Example | उपयोग |
|---|---|---|
| int | 25 | पूर्ण संख्या |
| float | 25.5 | दशमलव संख्या |
| str | "Hello" | Text |
| bool | True | True/False |
🧠 Practice Question
नीचे दिए गए Variables के Data Types पहचानिए:
a = 100
b = 10.5
c = "Python"
d = False
उत्तर:
- a → int
- b → float
- c → str
- d → bool
🎯 आज हमने क्या सीखा?
- Data Type क्या होता है?
- Integer क्या होता है?
- Float क्या होता है?
- String क्या होता है?
- Boolean क्या होता है?
- type() function का उपयोग कैसे करते हैं?
🐍 RBSE Python — Python Programming सीखें Step by Step