🐍 Pythonda ma'lumot tiplari (DATA TYPE)
from Baratov Muslimbek#python #datatype #tiplar
5-MAVZU:
🐍 Pythonda ma'lumot tiplari.
(DATA TYPE)
Dasturlashda ma'lumot tiplari muhim tushuncha.
Pytonda ma'lumot tiplari qurilishi quyidagicha toifalangan:
1️⃣ Matn tipi: str
2️⃣ Son tipi: int , float , complex
3️⃣ To'plam tipi: list , tuple , range
4️⃣ Ro'yhat tipi: dict
5️⃣ Set tipi: set, frozenset
6️⃣ Mantiqiy tip: bool
7️⃣ Binary tip: bytes , bytearray , memoryview

Tiplarni aniqlash:
Buning uchun siz type() funksiyasidan foydalanasiz.
Misol:
x = 5
print(type(x))
>>>
<class 'int'>
>>>
x = "Hello World" str
x = 20 int
x = 20.5 float
x = 1j complex
x = ["apple", "banana", "cherry"] list
x = ("apple", "banana", "cherry") tuple
x = range(6) range
x = {"name" : "John", "age" : 36} dict
x = {"apple", "banana", "cherry"} set
x = frozenset({"apple", "banana", "cherry"}) frozenset
x = True bool
x = b"Hello" bytes
x = bytearray(5) bytearray
x = memoryview(bytes(5)) memoryview
Ma'lumotni tipi bilan elon qilish:
Agar siz kiritayotgan malumot tipi aniq bo'lishini istasangiz unda quyidagi konstruksiyani qo'llashingiz zarur:
x = str("Hello World") str
x = int(20) int
x = float(20.5) float
x = complex(1j) complex
x = list(("apple", "banana", "cherry")) list
x = tuple(("apple", "banana", "cherry")) tuple
x = range(6)range
x = dict(name="John", age=36) dict
x = set(("apple", "banana", "cherry")) set
x = frozenset(("apple", "banana", "cherry")) frozenset
x = bool(5) bool
x = bytes(5) bytes
x = bytearray(5) bytearray
x = memoryview(bytes(5)) memoryview
https://t.me/uz_python