DEV Community

Nuriddin152
Nuriddin152

Posted on • Updated on

: )

update uchun masala
sample_set = {"Yellow", "Orange", "Black"}

sample_list = ["Blue", "Green", "Red"]
sample_set.update, (sample_list)

print(sample_set)

union-uchun misol
set1 = {10, 20, 30, 40, 50}
set2 = {30, 40, 50, 60, 70}

print(set1.union(set2))

difference-update() - masala
set1 = {10, 20, 30}

set2 = {20, 40, 50}
set1.difference_update(set2)
print(set1)

keys = ['Ten', 'Twenty', 'Thirty']
values = [10, 20, 30]
res_dict = dict(zip(keys, values))
print(res_dict)

None-qiymati yoq degani

Agar siz ma'lumotlar turini belgulamoqchi bo'lsangiz, quyidagi konstruktor funksiyalarudan foydalanishingiz mumkin:
x = str("Hello world")
x = int(20)
x = float(20.5)
x = complex(1j)
x = list(("Apple", "Banana", "Cherry"))
x = tuple(("aplle", "Banana", "Cherry"))
x = range(6) -- range
x = dict(name = "John", age = "36")
x = frozenset(("aplle", "banana," "chery"))
x = bool(5) #bool - Taqqoslash
x = bytes(5)
x = bytearray(5)
x = memoryview(bytes(5))

Python da 3 ta raqamli tur mavjud

integer - int - Bu butun sonlar uchun
float - bu kasr sonlar uchun
complex - murakkab sonlar uchun
x = 1 int
y = 2.8 float
z = 1j murakkab sonlar uchun

int - integer
int yoki butun son - bu musbat yoki manfiy, o'nli kasrsiz, cheksiz uzunlikdagi butun son
x = 1
y = 215648616611
z = -4623564

print(type(x))
print(type(y))
print(type(z))

float
Float, shuningdek, 100 ning kuchhini ko'rsatidh uchun "e" bilan ilmiy raqamlar bo'lishi mumkin
bir turdan ikkinchisiga o'tkazish
x = 1 int
x = 2.5 float
x = 11 complex
a = float (x)
b = int (y)
c = complex (z)

print(a)
print(b)
print(c)

Top comments (0)