Learning Python: The Ultimate Guide for Beginners to Coding with Python with Useful Tools



Download 2,02 Mb.
Pdf ko'rish
bet76/126
Sana01.01.2022
Hajmi2,02 Mb.
#285662
1   ...   72   73   74   75   76   77   78   79   ...   126
Bog'liq
Learning Python The Ultimate Guide for Beginners to Coding with

election_list = {
‘John Campbell’ : [‘Freedom Party’],
‘Eric Longman’: [‘Sovereign Nation Party’],
‘Amanda  Drill’:  [‘Freedom  Party,’  ‘  Women  Liberation
Movement’],
‘Condolence  Rice’:  [‘Democratic  Party,’  ‘  Sovereign  Nation
Party’],
‘Donald Trump’: [‘Republican Party,’ ‘Democratic Party’],
‘Nicolas Fred’: [‘Sovereign Nation Party’],
}


for name, party in election_list.items():
print(f “\n{name.title()}’s party are: ”)
for party in parties:
print (f “\t{party.title()}”)
In the first bolded line, we create a list. If you observe, some names have
one  political  party,  while  others  have  two.  We  then  loop  through  the
dictionary to run through the political party of each candidate.
John Campbell’s party are:
Freedom Party
Eric Longman’s party are:
Sovereign Nation Party
Amanda Drill’s party are:
Freedom Party
Women 
Liberation
Movement
Condolence Rice’s party are:
Democratic Party
Sovereign Nation Party
Donald Trump’s party are:
Republican Party
Democratic Party
Nicolas Fred’s party are:
Sovereign Nation Party
Exercise to Try
Write a program that creates three dictionaries, which represent
three different meals with each person choosing at least a meal
of their choice. Use “for loop” to scan through the list and prints
the choice of each individual.
Make  a  dictionary  list  comprising  of  your  favorite  pets.  The
dictionary must contain the type of pet, owner’s name, best food,
and unique sound. Next, loop through your pest list and display
two of this information in the list.


Create  a  list  of  your  favorite  cities  in  the  world.  Create  a  key-
value  dictionary  system  that  includes  the  name  of  the  city,
population,  currency,  and  contact  details  of  the  mayor.
Furthermore, print each city with at least three of the information
you want people to know.
Summary
In  this  section,  you  have  learned  what  dictionaries  are,  how  to  work  with
them and store information in it. Undoubtedly, you can write a program that
can access and modify each item in a dictionary. Additionally, you can loop
through  the  information  contained  in  your  dictionary.  You  can  also  loop
through a dictionary key, value, and key-value pairs. Furthermore, you can
nest multiple dictionaries in a list, nest dictionary in a dictionary, and nest
list in your dictionary.


Chapter 4: Conditional or Decision Statements
Introduction
In  programming,  we  normally  set  certain  conditions  and  decide  which
Download 2,02 Mb.

Do'stlaringiz bilan baham:
1   ...   72   73   74   75   76   77   78   79   ...   126




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