Kimlik operatörü Python #18

Published: 25 September 2019
on channel: Cebir Productions
104
5

#is
#python
#operatör

Video içeriği:

'''-------Kimlik operatörü-------

------id() fonksiyonu--------
id() fonksiyonu:Nesnelerin (id) kimliklerini,yani bellek adreslerini öğrenmemizi sağlar.
Not:python'da her nesnenin bir (id) kimlik numarısı vardır.
örnek1:
a="metin"
b=0
c=256
d=257
e=3.14
f=-1
g=-5
h=-6
i=True
print(id(a))
print(id(b))
print(id(c))
print(id(d))
print(id(e))
print(id(f))
print(id(g))
print(id(h))
print(id(i))

örnek2:
liste=[1,2,3]
demet=(1,2,3)
sözlük={"a":1,"b":2}
küme={1,2,3}
print(id(liste))
print(id(demet))
print(id(sözlük))
print(id(küme))


---------is operatörü----------------
1) is operatörü: Nesnelerin kimlik değerlerini karşılaştırmamızı şağlar.Başka bir deyişle
değişkenlere verdiğimiz değerlerin bellek adreslerini birbiri ile karşılaştırmamızı sağlar.
örnek1:
a = 1
b = 1
c = 0

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

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

örnek2:
a=255
b=256
c=-4
d=-5
a+=1
b+=1
c-=1
d-=1
print(hex(id(a)),"id=",id(a))
print(hex(id(b)),"id=",id(b))
print(hex(id(c)),"id=",id(c))
print(hex(id(d)),"id=",id(d))
print(a is 256)
print(b is 257)
print(c is -5)
print(d is -6)

#Not:python -5 ve 256 değerleri arası için bellekte yeni adres oluşturmaz.
#Yani aynı değere sahip iki değişken değeri için iki farklı bellek adresi oluşturmaz.ilk
#oluşturulan değeri kullanır.

örnek3:

x=-6
for y in range(-6,258):
print("x=",x,"y=",y,x is y)
x += 1

'''


On this page of the site you can watch the video online Kimlik operatörü Python #18 with a duration of hours minute second in good quality, which was uploaded by the user Cebir Productions 25 September 2019, share the link with friends and acquaintances, this video has already been watched 104 times on youtube and it was liked by 5 viewers. Enjoy your viewing!