Edit Template
Edit Template
Edit Template

Python Data Type

What is Python Data Type

Python Data Type : variable  में हम जब भी कोई data store करते हैं तो उसका एक type होता है, python में कई तरह के data type होते हैं जैसे : numeric, sequence, set, etc.  लिए इनके बारे में अच्छे से समझते हैं।

आसान भाषा मे कहे तो data type हमे बताता है की variable मे हम कैसी information को store कर रहे है क्या वो number है, text है या कुछ और।

Types of Data Type in Python

python मे अलग अलग types के information को store करने के लिए अलग अलग types के data type होते है। जैसे : – 

1.  Numeric data type : Numeric data type numbers को represent करता है जैसे: 1, -1, 1.5 जितने भी numbers होते हैं इन्हें numeric data type कहा जाता है। 

python में numeric data type तीन तरह के होते हैं. Integers, floating-point numbers, complex numbers. 

  • integers वह सभी numbers होते हैं जो बिना decimal point के होते हैं, यह positive, negative या zero हो सकते हैं जैसे : 1, -4, 0.
  • Floating point numbers वह numbers होते हैं जो decimal point के साथ होते हैं, जैसे : 3.15, – 1.2, 0.0 etc.
  • Complex numbers वह numbers होते हैं जो real और imaginary port को combine करते हैं,  जैसे : 1+3j, 2-5j, etc.

 

2.  Sequence data type : Sequence data type, text  represent करता है जैसे: string, list, tuple इनके बारे में अब आगे अच्छे से समझेंगे। 

Single and double quote के अंदर हम कुछ लिखते हैं तो यह string कहलाता है। 

Triple quote के अंदर हम कुछ लिखते हैं तो भी यह string कहलाता है इसका use हम multi line string के लिए करते हैं।

3.  Mapping type : Mapping type जैसे की dict यह key value pairs का unordered collection होता है, इसके uses को आगे समझेंगे। 

4.  Set type : Set type, set unique items का unordered collection होता है आपने math में set तो पढ़ा ही होगा कुछ इसी type का यह भी होता है इसके बारे में अब आगे समझेंगे। 

5.  Boolean type : Boolean type, true ओर false को represent करता है।

6. None type : None type हम जब भी कोई variable बनाते हैं और अगर उसमें कोई value ना दे तो उसमें एक rough value आ जाती है, but हम चाहते इसमें कोई value ना हो तो इसमें none को assign कर देते हैं। 

# Numeric Data Types
integer_value = 10   # int
float_value = 20.5   # float
complex_value = 3 + 4j  # complex

# Text Data Type
string_value = "Hello, Python!"  # str

# Sequence Data Types
list_value = [1, 2, 3, 4, 5]  # list (mutable)
tuple_value = (10, 20, 30)  # tuple (immutable)

# Set Data Types
set_value = {1, 2, 3, 4, 5}  # set (unordered, unique values)
frozenset_value = frozenset({10, 20, 30})  # frozenset (immutable set)

# Mapping Data Type
dict_value = {"name": "Alice", "age": 25}  # dictionary (key-value pairs)

# Boolean Data Type
bool_value = True  # bool (True or False)

# Displaying types
print(integer_value)
print(float_value)
print(complex_value)
print(string_value)
print(list_value)
print(tuple_value)
print(set_value)
print(frozenset_value)
print(dict_value)
print(bool_value)

What is Casting Function

किसी data के data type को किसी और data type में convert करने के लिए इस method का use करते हैं

Int :  जब हम किसी value को integer में convert करते हैं तो ‘int’ का use करते हैं। 

# Convert float and string to integer
float_num = 10.9
string_num = "25"

print(int(float_num))  # Output: 10 (Decimal part is removed)
print(int(string_num))  # Output: 25 (String is converted to int)

Float :  जब हम किसी value को floating point number में convert करते हैं तो ‘float’ का use करते हैं

# Convert int and string to float
int_num = 10
string_float = "15.75"

print(float(int_num))  # Output: 10.0
print(float(string_float))  # Output: 15.75

Complex : जब हम किसी value को complex number में convert करते हैं तो ‘complex’ का use करते हैं.

# Convert int and float to complex
int_num = 5
float_num = 2.3

print(complex(int_num))  # Output: (5+0j)
print(complex(float_num))  # Output: (2.3+0j)

# Convert two numbers into a complex number (real + imaginary)
print(complex(3, 4))  # Output: (3+4j)

String : जब हम किसी value को string में convert करते हैं तो ‘str’ का use करते हैं

# Convert int, float, and complex to string
int_value = 100
float_value = 25.6
complex_value = 3 + 5j

print(str(int_value))  # Output: "100"
print(str(float_value))  # Output: "25.6"
print(str(complex_value))  # Output: "(3+5j)"

उम्मीद करते है कि आपको python data type अच्छे समझ मे आ गया होगा । अपने learning को continue रखने के लिए next button पर click करे,

Some important questions in this tutorial

What is Python Data Type, python me data type kya hota hai.

Add a comment...

Your email address will not be published. Required fields are marked *

  • All Posts
  • Artificial Intelligence
  • Computer Fundamentals
  • Computer Networks
  • Data Analytics
  • Data Science
  • DBMS
  • Deep Learning
  • Digital Fundamentals
  • DSA with Python
  • Excel
  • Exercise
  • Git & Github
  • Machine Learning
  • Matplotlib
  • Natural Language Processing
  • NumPy
  • Operating System
  • Pandas-s
  • Power BI
  • Python Tutorial
  • Scikit-learn
  • Seaborn
  • SQL & MySQL
Python List

Python Tutorial Python Introduction Identation & Comments Python Variable Python Data Type Python Operators Conditional Statements Python Loops Python String...

Python String

Python Tutorial Python Introduction Identation & Comments Python Variable Python Data Type Python Operators Conditional Statements Python Loops Python String...

Python Loops

Python Tutorial Python Introduction Identation & Comments Python Variable Python Data Type Python Operators Conditional Statements Python Loops Hamburger Toggle...

Conditional Statements

Python Tutorial Python Introduction Identation & Comments Python Variable Python Data Type Python Operators Conditional Statements Python Loops Hamburger Toggle...

Python Operators

Python Tutorial Python Introduction Identation & Comments Python Variable Python Data Type Python Operators Conditional Statements Python Loops Hamburger Toggle...

Python Data Type

Python Tutorial Python Introduction Identation & Comments Python Variable Python Data Type Python Operators Conditional Statements Python Loops Hamburger Toggle...

Scikit-learn

Scikit-learn Tutorial Scikit-learn Hamburger Toggle Menu Edit Template Scikit learn What is Scikit-learn Scikit learn एक python library है जिसका...

Pandas

Pandas Tutorial Pandas Hamburger Toggle Menu Edit Template Pandas What is Pandas pandas  एक python library है, जिसका use हम...

NumPy

NumPy Tutorial NumPy Hamburger Toggle Menu Edit Template NumPy What is NumPy matplotlib का use हम data visualization के लिए...

Edit Template
Scroll to Top