आपकी ऑफलाइन सहायता

BACK
49

सी प्रोग्रामिंग

149

पाइथन प्रोग्रामिंग

49

सी प्लस प्लस

99

जावा प्रोग्रामिंग

149

जावास्क्रिप्ट

49

एंगुलर जे.एस.

69

पी.एच.पी.
माय एस.क्यू.एल.

99

एस.क्यू.एल.

Free

एच.टी.एम.एल.

99

सी.एस.एस.

149

आर प्रोग्रामिंग

39

जे.एस.पी.





डाउनलोड पी.डी.एफ. ई-बुक्स
Python - Data Types

Python में variables के अन्दर अलग-अलग types की values store की जाती है जैसे कि किस variable के अन्दर numeric value तो किसी दूसरे variable के अन्दर alphabetic value store की जाती है, इसे ही 'Data Types' कहा जाता है |

Types of Data in Python

Python में छह प्रकार के Data Types होते है |

  1. Number
  2. String
  3. List
  4. Tuple
  5. Dictionary
  6. Set

1. Number Data Types in Python

Number Data Types के तीन प्रकार होते है |

  1. Integer Number Data Type
  2. Floating-point Number Data Type
  3. Complex Number Data Type

Note : type() function का इस्तेमाल data type check करने के लिए किया जाता है |


1.1 Integer Number Data Type

Integer data type ये normal numeric values होती है | integer numbers को अपूर्णांकित हिस्सा नहीं होता है |

Source Code :
a = 5
b = 12545885
c = 412154986446513513878678541351865465

print(a)
print(b)
print(c)
print(type(a))
print(type(b))
print(type(c))
Output :
5
12545885
412154986446513513878678541351865465
<class 'int'>
<class 'int'>
<class 'int'>

1.2 Floating-point Number Data Type

Floating-point numbers को अपूर्णांकित हिस्सा होता है | Python में floating-point number के लिए कोई मर्यादा नहीं होती है |

Source Code :
a = 5.0
b = 12545885.568444444444445
c = 412154986446513513878678541351865465.4547878541516546845

print(a)
print(b)
print(c)
print(type(a))
print(type(b))
print(type(c))
Output :
5.0
12545885.568444444
4.121549864465135e+35
<class 'float'>
<class 'float'>
<class 'float'>

1.3 Complex Number Data Type

Complex data type 'a + bj' इस form में होता है इसमे 'a' ये real part होता है और 'b' ये imaginary part होता है |

Source Code :
a = 1 + 4j
b = 5 + 4758499j

print(a)
print(b)
print(type(a))
print(type(b))
Output :
(1+4j)
(5+4758499j)
<class 'complex'>
<class 'complex'>



String Data Type in Python

String ये characters का set होता है | characters; letters, numbers या special symbols हो सकते है | Python में single(' ') या double(" ") quotes के अन्दर लिखे जाते है | String ये immutable data type है |

Source Code :
str1 = "Hello World"
str2 = "Hello Friends"

print(str1)
print(str2)
Output :
Hello World
Hello Friends

ज्यादातर Programming languages में string को index में print किया जाता है उसी प्रकार से Python में भी string को indexes से print किया जाता है | string के सबसे पहले character को index '0' से शुरू होती है और string के सबसे आखिरी index '-1' होती है |

Source Code :
str = "Hello World"
print("First letter in string :", str[0])
print("Last letter in string :", str[-1])
print("Second last letter in string :", str[-2])
Output :
First letter in string : H
Last letter in string : d
Second last letter in string : l

String के बारे में अधिक जानने के लिए यहाँ click करे |



List Data Type in Python

Python के list data type में एक से ज्यादा items होते है | हर एक item को comma(,) से seperate किया जाता है | list के सभी items को square bracket([]) के अन्दर close किये जाता है |

List ये एक compound data type है जिसमे किसी भी data types के items लिए जा सकते है | list ये एक mutable data type है | इन data type के items की values change की जा सकती है |

Source Code :
list = [1, "Hello", 5.6, (1, "Hii")]

for i in list:
    print(i)
Output :
1
Hello
5.6
(1, 'Hii')

List Data Type के बारे में अधिक जानने के लिए यहाँ click करे |



Tuple Data Type in Python

Python के list data type में एक से ज्यादा items होते है | ये list data type के जैसे ही होता है | हर एक item को comma(,) से seperate किया जाता है | Tuple के सभी items को parenthesis(()) के अन्दर close किये जाता है |

Tuple ये एक compound data type है जिसमे किसी भी data types के items लिए जा सकते है | list ये एक immutable data type है | इन data type के items की values change नहीं की जा सकती है |

Source Code :
tuple = (1, "Hello", 5.6, (1, "Hii"))

for i in tuple:
    print(i)

tuple[0] = 3  #trying to changing 0th index
print(tuple[0])
Output :
1
Hello
5.6
(1, 'Hii')
Traceback (most recent call last):
    tuple[0] = 3  #trying to changing 0th index
TypeError: 'tuple' object does not support item assignment

Tuple Data Type के बारे में अधिक जानने के लिए यहाँ click करे |



Dictionary Data Type in Python

Dictionary Data Type में keys और values की pairs होती है | हर key value के pair को comma(,) से और key और value को colon(:) से seperate किया जाता है | Dictionary के सभी keys और values को curly braces({}) में लिखा जाता है | ये एक immutable data type है |

Source Code :
dict = {1:"H", 5:"e", 7:"l", 8:"l", 9:"o"}

print(dict[5])
print(dict[9])
Output :
e
o

Dictionary Data Type के बारे में अधिक जानने के लिए यहाँ click करे |



Set Data Type in Python

Set Data Type ये items का unordered collection होता है | set में दिए हुआ हर एक item नया होता है | अगर duplicate item मिल जाता है तो उसे remove किया जाता है | set data type के items को curly braces({}}) के अन्दर लिखा जाता है |

Source Code :
set1 = {"Ramesh", "Suresh", "Kamlesh"}
for i in set1:
    print(i)
    
set2 = {3, 5, 8, 7, 1, 3}
for j in set2:
    print(j)
Output :
Suresh
Kamlesh
Ramesh
1
3
5
7
8

Set Data Type के बारे में अधिक जानने के लिए यहाँ click करे |