Algorithms For Dummies


Storing Data Using Sets, Lists, and Tuples



Download 7,18 Mb.
Pdf ko'rish
bet179/651
Sana15.07.2021
Hajmi7,18 Mb.
#120357
1   ...   175   176   177   178   179   180   181   182   ...   651
Bog'liq
Algorithms

Storing Data Using Sets, Lists, and Tuples

When working with algorithms, it’s all about the data. Python provides a host of 

methods for storing data in memory. Each method has advantages and 

disadvantages. Choosing the most appropriate method for your particular need is 

important. The following sections discuss three common techniques used for 

storing data for data science needs.



Creating sets

Most people have used sets at one time or another in school to create lists of items 

that belong together. These lists then became the topic of manipulation using 

math operations such as intersection, union, difference, and symmetric differ-

ence. Sets are the best option to choose when you need to perform membership 

testing and remove duplicates from a list. You can’t perform sequence-related 

tasks using sets, such as indexing or slicing. To see how you can work with sets, 

start a copy of IPython and type the following code:

SetA = set(['Red', 'Blue', 'Green', 'Black'])

SetB = set(['Black', 'Green', 'Yellow', 'Orange'])

SetX = SetA.union(SetB)

SetY = SetA.intersection(SetB)

SetZ = SetA.difference(SetB)

You now have five different sets to play with, each of which has some common 

elements. To see the results of each math operation, type print(‘{0}\n{1}\n{2}’.



86

 

   


  PART 1 


Download 7,18 Mb.

Do'stlaringiz bilan baham:
1   ...   175   176   177   178   179   180   181   182   ...   651




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2025
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