Chapter 3Python Tutorial~1 min read
Data Types in Python
Data चे प्रकार
Python मध्ये data वेगवेगळ्या प्रकारात save होतो — numbers, text, true/false, lists, dictionaries. प्रत्येक type साठी वेगळ्या operations आहेत. type() function वापरून कोणताही variable चा type check करता येतो.
Numeric Types
int, float, complex
python
# int — पूर्ण संख्या
age = 20
marks = -5
print(type(age)) # <class 'int'>
# float — दशांश संख्या
pi = 3.14159
height = -9.0
print(type(pi)) # <class 'float'>
# complex — जटिल संख्या (advanced math)
c = 6 + 2j
print(type(c)) # <class 'complex'>String, Boolean आणि None
str, bool, None
python
# str — text
name = "Rahul"
city = 'Pune'
print(type(name)) # <class 'str'>
# bool — True किंवा False
is_student = True
has_car = False
print(type(is_student)) # <class 'bool'>
# None — कोणतीही value नाही (null सारखे)
result = None
print(type(result)) # <class 'NoneType'>Collection Types
list, tuple, dict, set
python
# list — ordered, changeable collection []
fruits = ["Apple", "Mango", "Banana"]
mixed = [1, "hello", 3.14, True]
# tuple — ordered, UNCHANGEABLE collection ()
coords = (10.5, 20.3)
colors = ("Red", "Green", "Blue")
# dict — key:value pairs {}
person = {"name": "Karan", "age": 19, "city": "Pune"}
# set — unique values, no duplicates {}
unique_nums = {1, 2, 3, 2, 1}
print(unique_nums) # {1, 2, 3} — duplicates गेले!💡
list vs tuple: दोन्ही ordered आहेत, पण list mutable (बदलता येतो) आणि tuple immutable (बदलता येत नाही) आहे. Coordinates, RGB values यासाठी tuple वापरतात.
✅ Key Points — लक्षात ठेवा
- ▸int, float, complex — numbers
- ▸str — text, quotes मध्ये
- ▸bool — True किंवा False (capital T/F)
- ▸None — null value
- ▸list [], tuple (), dict {key:val}, set {} — collections
- ▸type() — कोणत्याही value चा type दाखवतो
0/12 chapters पूर्ण