Python Data Types क्या हैं? int, float, str, list, tuple, dict & set | RBSE Class 12

इस लेख में: Python Data Types क्या हैं, Python के built-in data types, int, float, complex, bool, str, list, tuple, set और dictionary को examples के साथ आसान हिंदी में समझेंगे।

Python Data Type क्या है?

किसी value या data का प्रकार Data Type कहलाता है। Programming में अलग-अलग प्रकार के data के साथ अलग-अलग operations किए जाते हैं, इसलिए data का type समझना बहुत महत्वपूर्ण है।

उदाहरण के लिए:

age = 18
name = "Rahul"
marks = 85.5

यहाँ age में integer value, name में string value और marks में floating-point value रखी गई है।

Python में Data Types क्यों जरूरी हैं?

Python में data type यह समझने में मदद करता है कि किसी value के साथ किस प्रकार का operation किया जा सकता है।

उदाहरण:

a = 10
b = 20

print(a + b)

यहाँ दोनों values numbers हैं, इसलिए addition किया जा सकता है।

Python के प्रमुख Built-in Data Types

Data Type उदाहरण विवरण
int 10 पूर्ण संख्या
float 10.5 दशमलव संख्या
complex 2 + 3j Complex number
bool True / False Boolean value
str "Python" Text/String
list [10, 20, 30] Ordered collection
tuple (10, 20, 30) Ordered immutable collection
set {10, 20, 30} Unique values का collection
dict {"name":"Rahul"} Key-value collection

1. Integer Data Type – int

int का उपयोग whole numbers या पूर्ण संख्याओं को represent करने के लिए किया जाता है।

उदाहरण:

age = 18
marks = 95
year = 2026

इन values का data type integer है।

age = 18

print(type(age))

यहाँ type() function variable का data type check करता है।

2. Float Data Type – float

float का उपयोग decimal या floating-point numbers के लिए किया जाता है।

height = 5.8
price = 99.50
percentage = 85.5

उदाहरण:

marks = 85.5

print(type(marks))

3. Complex Data Type – complex

Python में complex numbers को complex data type के रूप में represent किया जाता है।

z = 2 + 3j

print(z)
print(type(z))

Complex number में real और imaginary parts होते हैं। Python में imaginary part को represent करने के लिए j का उपयोग किया जाता है।

4. Boolean Data Type – bool

Boolean data type में मुख्यतः दो values होती हैं: True और False

is_student = True
is_teacher = False

Boolean values conditions और decision making में बहुत उपयोगी होती हैं।

5. String Data Type – str

String का उपयोग text या characters के sequence को store करने के लिए किया जाता है।

name = "Rahul"
city = "Jaipur"
course = "Python"

String को single quotes या double quotes में लिखा जा सकता है।

name1 = 'Rahul'
name2 = "Rahul"

String का Example

message = "Welcome to Python"

print(message)

6. List Data Type – list

List एक ordered collection है जिसमें कई values को एक साथ रखा जा सकता है। List में अलग-अलग प्रकार की values भी रखी जा सकती हैं।

marks = [80, 85, 90, 95]

List की values को index के माध्यम से access किया जा सकता है।

marks = [80, 85, 90, 95]

print(marks[0])

Output:

80

List Mutable होती है

Python list में मौजूद elements को modify किया जा सकता है।

marks = [80, 85, 90]

marks[0] = 95

print(marks)

Output:

[95, 85, 90]

7. Tuple Data Type – tuple

Tuple भी ordered collection है। इसे सामान्यतः parentheses में लिखा जाता है।

numbers = (10, 20, 30, 40)

Tuple को index के माध्यम से access किया जा सकता है।

numbers = (10, 20, 30)

print(numbers[1])

Output:

20
Important: Tuple immutable होता है। इसका अर्थ है कि tuple बनने के बाद उसके existing elements को सामान्य assignment द्वारा बदला नहीं जा सकता।

8. Set Data Type – set

Set unique elements का collection है। इसमें duplicate values को एक ही element के रूप में रखा जाता है।

numbers = {10, 20, 30, 20}

print(numbers)

Set में duplicate 20 को दो अलग elements के रूप में नहीं रखा जाएगा।

9. Dictionary Data Type – dict

Dictionary data को key-value pairs के रूप में store करती है।

student = {
    "name": "Rahul",
    "age": 18,
    "marks": 85
}

यहाँ:

  • name एक key है।
  • Rahul उसकी value है।
  • age एक key है।
  • 18 उसकी value है।

Dictionary से value access करने का उदाहरण:

student = {
    "name": "Rahul",
    "age": 18
}

print(student["name"])

Output:

Rahul

type() Function क्या है?

Python में type() function का उपयोग किसी object या value का data type जानने के लिए किया जाता है।

x = 100

print(type(x))

एक साथ कई examples:

a = 10
b = 10.5
c = "Python"
d = True

print(type(a))
print(type(b))
print(type(c))
print(type(d))

Python Data Types का Practical Example

name = "Rahul"
age = 18
marks = 87.5
is_student = True

print(name)
print(age)
print(marks)
print(is_student)

इस program में अलग-अलग प्रकार की values को variables में store किया गया है।

Mutable और Immutable Data Types

Python के कुछ objects को बनने के बाद modify किया जा सकता है और कुछ को modify नहीं किया जा सकता।

Category Examples
Mutable list, dict, set
Immutable int, float, bool, str, tuple
Exam Point: Mutable object की contents को modify किया जा सकता है, जबकि immutable object को बनने के बाद उसी object की contents को सामान्यतः बदला नहीं जा सकता।

List और Tuple में अंतर

List Tuple
List mutable होती है। Tuple immutable होता है।
Square brackets [] का उपयोग किया जाता है। Parentheses () का उपयोग किया जाता है।
उदाहरण: [10, 20, 30] उदाहरण: (10, 20, 30)

Python Data Types का Quick Revision

Data Type Example Use
int 100 Whole numbers
float 10.5 Decimal numbers
complex 2 + 3j Complex numbers
bool True Boolean values
str "Hello" Text
list [1, 2, 3] Collection
tuple (1, 2, 3) Immutable collection
set {1, 2, 3} Unique collection
dict {"name":"Ram"} Key-value data

RBSE Class 12 Important Questions

  1. Data Type क्या है?
  2. Python के कोई पाँच built-in data types लिखिए।
  3. int और float data type में क्या अंतर है?
  4. String क्या है?
  5. List क्या है?
  6. Tuple क्या है?
  7. List और Tuple में अंतर लिखिए।
  8. Set क्या है?
  9. Dictionary क्या है?
  10. Boolean data type की values कौन-कौन सी हैं?
  11. type() function का क्या उपयोग है?
  12. Mutable और Immutable data types में अंतर बताइए।

Frequently Asked Questions (FAQs)

Python Data Type क्या है?

Data type किसी value या object के प्रकार को बताता है और यह निर्धारित करने में मदद करता है कि उस data के साथ किस प्रकार के operations किए जा सकते हैं।

Python में कितने Data Types होते हैं?

Python में कई built-in data types उपलब्ध हैं, जिनमें numeric types, boolean, string, list, tuple, set और dictionary प्रमुख हैं।

Python में int क्या है?

int data type का उपयोग integer या पूर्ण संख्याओं को represent करने के लिए किया जाता है।

Python में float क्या है?

float data type का उपयोग floating-point या decimal numbers के लिए किया जाता है।

Python में list और tuple में क्या अंतर है?

List mutable होती है जबकि tuple immutable होता है। List के लिए सामान्यतः square brackets और tuple के लिए parentheses का उपयोग किया जाता है।

Python में dictionary क्या है?

Dictionary key-value pairs के रूप में data को store करने वाला built-in collection type है।

अब अगला Topic पढ़ें

RBSE Python Study Tip: Data Types को केवल याद न करें। प्रत्येक type का छोटा program लिखकर उसका output और type() function का result स्वयं check करें। इससे concepts लंबे समय तक याद रहते हैं।
Official Reference:

Python के built-in data types की detailed जानकारी के लिए Python की official documentation देखें।

Python Standard Types Documentation