Python Data Types In Hindi

📔 : Python 🔗

Programming में Data Type बहुत ही important concept है। क्योंकि Data Type के according ही हम किसी variable के लिए logic implement करते हैं।


Data Type का simply मतलब है किसी variable का type, जिससे हमें पता चल सके कि कोई variable किस type की value hold किये हुए है , या in future किस type की value hold करेगा।


Important
Data Type के case में Python बहुत ही flexible language है , अगर आपको Java या C की थोड़ी भी knowledge है तो आपको याद होगा कि किसी भी तरह के variable को define करने से पहले हमें उस variable का Data Type define करना पड़ता था। मतलब हमें variable define करते समय ये बताना पड़ता था कि वह variable किस type की value store करने जा रहा है।


Python में किसी भी variable का type किसी programmer द्वारा नहीं किया जा सकता है , यह runtime में ही assign की गयी value के according decide होता है कि variable किस type का है। means हमें variable define करते समय Data Type define नहीं करना पड़ता है , हम directly उस value को assign कर देते हैं।
For Example -

name = "Rahul Kumar"

Python में built in Data Types कुछ प्रकार हैं -

Data Types
Text : str
Numeric : int, float, complex
Sequence : list, tuple, range
Binary : bytes, bytearray, memoryview
Mapping : dict
Set : set, frozenset
Boolean : bool

Python Get variable Data Type

Python में किसी भी variable की Data Type जानने के लिए type() function का use किया जाता है।

Copy Fullscreen Close Fullscreen Run
age = 90
name = 'Some Name'
print(type(age))
print(type(name))
Output
C:\Users\Rahulkumar\Desktop\python>python data_type.py
<class 'int'>
<class 'str'>

Python Numeric Data Type

Numeric में सभी numeric values होती है जिन पर हम arithmetic operations perform कर सकें। इसमें भी तीन तरह की values होती हैं -

  1. int : without decimal numbers like - 1, 4, 67, -45
  2. float : with decimal numbers like - 3.5, 6.7, 8.00
  3. complex : alpha numric like - 3h, 5l

Copy Fullscreen Close Fullscreen Run
int_var1 = 90
int_var2 = -10
float_var1 = 34.90
float_var2 = -134.00
complex_var1 = 4j
complex_var2 = -50j

print(type(int_var1))
print(type(int_var2))
print(type(float_var1))
print(type(float_var2))
print(type(complex_var1))
print(type(complex_var2))
Output
C:\Users\Rahulkumar\Desktop\python>python py_numeric_type.py
<class 'int'>
<class 'int'>
<class 'float'>
<class 'float'>
<class 'complex'>
<class 'complex'>

Python String Data Type

String में सभी single या double quoted values आती हैं।
Example -

Copy Fullscreen Close Fullscreen Run
str_var1 = 'Single Quoted'
str_var2 = "Double Quoted"
str_var3 = """multiline
String"""

print(type(str_var1))
print(type(str_var2))
print(type(str_var3))
Output
C:\Users\Rahulkumar\Desktop\python>python py_numeric_type.py
<class 'str'>
<class 'str'>
<class 'str'>

Python Boolean Data Type

Boolean में सिर्फ दो values True , False होती हैं।
For Example -

Copy Fullscreen Close Fullscreen Run
bool_var1 = True
bool_var2 = False
print(type(bool_var1))
print(type(bool_var2))
Output
C:\Users\Rahulkumar\Desktop\python>python py_bool_type.py
<class 'bool'>
<class 'bool'>

Python Sequence Data Type

Sequence Type में basically बो सभी types होते हैं जिनमे एक से अधिक values store होती हैं like : list, tuple, range

Python Mapping Data Type

जहाँ एक से अधिक values को key - value pair में store करते हैं।:dictionary

Related Topics :

Rahul Kumar

Rahul Kumar

Hi ! I'm Rahul Kumar Rajput founder of learnhindituts.com. I'm a software developer having more than 4 years of experience. I love to talk about programming as well as writing technical tutorials and blogs that can help to others. I'm here to help you navigate the coding cosmos and turn your ideas into reality, keep coding, keep learning :)

Get connected with me. :) LinkedIn Twitter Instagram Facebook

b2eprogrammers