Python Data Types
Python data types tell us what kind of value a variable can store. Python figures this out automatically when you assign a value. Different types are used to store different kinds of data like numbers, text, or lists.
Python में data types यह बताते हैं कि एक variable किस प्रकार का डेटा स्टोर करता है। Python अपने आप type को पहचान लेता है जब आप कोई value assign करते हैं। अलग-अलग type अलग-अलग तरह का डेटा स्टोर करने के लिए होते हैं जैसे नंबर, टेक्स्ट या लिस्ट।
Example 1: Integer
x = 10
print(type(x))
Output:
<class 'int'>
An integer represents whole numbers like 1, 2, 100. Used for counting or indexing.
Integer पूरे नंबर होते हैं जैसे 1, 2, 100। इनका इस्तेमाल गिनती या इंडेक्स के लिए होता है।
Example 2: Float
y = 3.14
print(type(y))
Output:
<class 'float'>
Float is a number with a decimal point. Used for precision values like 3.14 or 0.5.
Float दशमलव संख्या होती है जैसे 3.14 या 0.5। इसका उपयोग सटीक मानों के लिए किया जाता है।
Example 3: String
name = 'Python'
print(type(name))
Output:
<class 'str'>
String is used to store text inside quotes. Can be single or double quotes.
String का उपयोग टेक्स्ट स्टोर करने के लिए होता है। यह ' ' या " " में लिखा जाता है।
Example 4: Boolean
flag = True
print(type(flag))
Output:
<class 'bool'>
Boolean stores True or False values. Used for conditions and logic.
Boolean True या False वैल्यू को स्टोर करता है। इसका उपयोग conditions और logic में होता है।
Example 5: List
fruits = ['apple', 'banana', 'mango']
print(type(fruits))
Output:
<class 'list'>
A list is an ordered, changeable collection of items. Allows duplicates and different data types.
List एक ordered और changeable collection होती है जिसमें अलग-अलग और duplicate values हो सकती हैं।
Example 6: Tuple
colors = ('red', 'green', 'blue')
print(type(colors))
Output:
<class 'tuple'>
A tuple is like a list but immutable (cannot be changed).
Tuple list की तरह होता है लेकिन इसे बाद में बदला नहीं जा सकता। यह fix रहता है।
Example 7: Dictionary
student = {'name': 'Aman', 'age': 20}
print(type(student))
Output:
<class 'dict'>
A dictionary stores data in key-value pairs. Keys are unique and used to access values.
Dictionary में डेटा key-value pairs में store होता है। Keys unique होती हैं और value access करने के लिए use होती हैं।
Example 8: Set
unique_nums = {1, 2, 3}
print(type(unique_nums))
Output:
<class 'set'>
Set is an unordered collection that only stores unique values. No duplicates allowed.
Set एक unordered collection होता है जिसमें केवल unique values होती हैं। डुप्लिकेट नहीं होते।