Python में Data Type यह बताता है कि किसी variable में किस प्रकार का data store है। Python में data type को manually declare नहीं करना पड़ता, Python interpreter value देखकर data type पहचान लेता है।
Example :
x = 10
name = "Python"
print(type(x))
print(type(name))
Number
Python में Number Data Types का उपयोग संख्याओं (Numbers) को store और process करने के लिए किया जाता है। Python में numbers को अलग-अलग प्रकार में divide किया गया है ताकि अलग-अलग प्रकार की calculations आसानी से की जा सकें।
Python के मुख्य Number Data Types:
- int (Integer)
- float (Floating Point Number)
- complex (Complex Number)
1. Integer Data Types (int)
- Integer वह संख्या होती है जिसमें decimal point नहीं होता हैं। इसमें positive, negative और zero सभी प्रकार की संख्याएँ store हो सकती हैं।
- Python में integer की कोई fixed limit नहीं होती। यह memory उपलब्ध होने तक बड़ी संख्या store कर सकता है।
Syntax :
variable_name = integer_value
Example :
age = 25
salary = 50000
temperature = -10
print(age)
print(salary)
print(temperature)
Output :
25
50000
-10
2. Float Number Data types
- Float (Floating Point Number) Python का एक numeric data type है जिसका उपयोग दशमलव (decimal point) वाली संख्याओं को store करने के लिए किया जाता है।
- Python का float सामान्यतः 64-bit double precision floating point format का उपयोग करता है।
Example :
price = 99.99
height = 5.8
print(price)
print(height)
Output :
99.99
5.8
3. Complex Number Data Types
Python में Complex Number एक ऐसा numeric data type है जिसमें Real Part (वास्तविक भाग) और Imaginary Part (काल्पनिक भाग) दोनों होते हैं।
Complex number का सामान्य रूप:
जहाँ:
- a = Real Part (वास्तविक संख्या)
- b = Imaginary Part (काल्पनिक संख्या)
- j = Imaginary unit (√-1)
Syntax :
variable_name = real_part + imaginary_partj
Example :
x = 5 + 3j
print(x)
Output :
(5+3j)
