Python Data Types | LiveCodeProgramming

Python Data Types

Python data types define the kind of value a variable can hold. Python detects the type automatically when a value is assigned. Each data type serves a different purpose such as storing numbers, text, collections, or binary data.

Python में data types यह बताते हैं कि एक variable किस प्रकार का डेटा रख सकता है। Python अपने आप type पहचान लेता है जब आप कोई value देते हैं। हर data type का अलग उद्देश्य होता है जैसे नंबर, टेक्स्ट, collections, या binary डेटा रखना।

Integer
x = 10
print(type(x))

Output:

<class 'int'>

Integer represents whole numbers.

Integer पूरे नंबर होते हैं।

Float
y = 3.14
print(type(y))

Output:

<class 'float'>

Float is a number with a decimal.

Float दशमलव संख्या होती है।

Complex
z = 2 + 3j
print(type(z))

Output:

<class 'complex'>

Complex numbers have a real and imaginary part.

Complex numbers में real और imaginary दोनों भाग होते हैं।

String
name = 'Python'
print(type(name))

Output:

<class 'str'>

String stores text inside quotes.

String में टेक्स्ट quotes में रखा जाता है।

Boolean
flag = True
print(type(flag))

Output:

<class 'bool'>

Boolean stores True or False.

Boolean True या False रखता है।

List
fruits = ['apple', 'banana']
print(type(fruits))

Output:

<class 'list'>

List is an ordered, changeable collection.

List एक ordered, changeable collection होती है।

Tuple
colors = ('red', 'green')
print(type(colors))

Output:

<class 'tuple'>

Tuple is like a list but immutable.

Tuple list की तरह होता है लेकिन इसे बदला नहीं जा सकता।

Range
r = range(5)
print(type(r))

Output:

<class 'range'>

Range generates a sequence of numbers.

Range नंबरों की एक श्रृंखला बनाता है।

Dictionary
student = {'name': 'Aman', 'age': 20}
print(type(student))

Output:

<class 'dict'>

Dictionary stores key-value pairs.

Dictionary में key-value pairs स्टोर होते हैं।

Set
unique_nums = {1, 2, 3}
print(type(unique_nums))

Output:

<class 'set'>

Set stores unique values without order.

Set में unique values होती हैं और order नहीं होता।

Frozenset
fs = frozenset({1, 2, 3})
print(type(fs))

Output:

<class 'frozenset'>

Frozenset is an immutable set.

Frozenset एक immutable set है।

Bytes
b = b'hello'
print(type(b))

Output:

<class 'bytes'>

Bytes stores immutable sequences of bytes.

Bytes immutable byte sequences रखता है।

Bytearray
ba = bytearray(5)
print(type(ba))

Output:

<class 'bytearray'>

Bytearray stores mutable sequences of bytes.

Bytearray mutable byte sequences रखता है।

Memoryview
mv = memoryview(b'hello')
print(type(mv))

Output:

<class 'memoryview'>

Memoryview is a view object of bytes.

Memoryview bytes का view object होता है।

NoneType
n = None
print(type(n))

Output:

<class 'NoneType'>

NoneType represents the absence of a value.

NoneType value की अनुपस्थिति दर्शाता है।