Author Dusty Phillips Reviewers



Download 2,95 Mb.
Pdf ko'rish
bet171/183
Sana20.07.2022
Hajmi2,95 Mb.
#831085
1   ...   167   168   169   170   171   172   173   174   ...   183
Bog'liq
python3-oop

my_artists is to bands:
issuperset: True
issubset: False
difference: {'Sarah Brightman', 'Vixy and Tony'}
********************
bands is to my_artists:
issuperset: False
issubset: True
difference: set()
The 
difference
method, in the second case, returns an empty set, since there are
no items in 
bands
that are not in 
my_artists
.
The 
union

intersection
, and 
difference
methods can all take multiple sets as 
arguments; they will return, as we might expect, the set that is created when the 
operation is called on all the parameters.
www.it-ebooks.info


Chapter 6
[
 177 
]
So the methods on sets clearly suggest that sets are meant to operate on other sets
and that they are not just containers. If we have data coming in from two different 
sources and need to quickly combine them in some way, to determine where the data 
overlaps or is different, we can use set operations to efficiently compare them. Or 
if we have data incoming that may contain duplicates of data that has already been 
processed, we can use sets to compare the two and process only the new data.
Finally, it is valuable 
to know that sets are much more efficient than lists when 
checking for membership using the 
in
keyword. If you use the syntax 
value in 
container
on a set or a list, it will return 
True
if one of the elements in 
container
is 
equal to 
value
and 
False
otherwise. However, in a list, it will look at every object in 
the container until it finds the value, whereas in a set, it simply hashes the value and 
checks for membership. This means that a set will find the value in the same amount 
of time no matter how big the container is, but a list will take longer and longer to 
search for a value as the list contains more and more values.

Download 2,95 Mb.

Do'stlaringiz bilan baham:
1   ...   167   168   169   170   171   172   173   174   ...   183




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish