99
10.
copy()
metodi lug'at nusxasini qaytaradi
kitob={
‘nom’: ‘Python asoslari’,
‘muallif’: ‘M.Mamarajabov’,
‘yil’:2021,
‘adadi’:500
}
kitob_yangi=kitob.copy()
print(kitob_yangi)
{'nom': 'Python asoslari', 'muallif':
'M.Mamarajabov', 'yil': 2021, 'adadi':
500}
11.
dict()
funksiyasi lug'at nusxasini qaytaradi
kitob={
‘nom’: ‘Python asoslari’,
‘muallif’: ‘M.Mamarajabov’,
‘yil’:2021,
‘adadi’:500
}
kitob_yangi=dick(kitob)
print(kitob_yangi)
{'nom': 'Python asoslari', 'muallif':
'M.Mamarajabov', 'yil': 2021, 'adadi':
500}
12.
setdefault()
metodi belgilangan kalit qiymatini qaytaradi.
Agar kalit
bo'lmasa: kalitni belgilangan qiymat bilan kiriting
kitob={
‘nom’: ‘Python asoslari’,
‘muallif’: ‘M.Mamarajabov’,
‘yil’:2021,
‘adadi’:500
}
2021
100
a=kitob.setdefault(“yil”)
print(a)
13.Pythonda ichma-ich lug’atlardan foydalanish mumkin
kitob={
‘kitob1’:{
‘nom’: ‘Python asoslari’,
‘muallif’: ‘M.Mamarajabov’,
‘yil’:2021,
‘adadi’:500},
‘kitob2’:{
‘nom’: ‘C++’,
‘muallif’: ‘R.To’rayev’,
‘yil’:2020,
‘adadi’:200},
‘kitob3’:{
‘nom’: ‘PHP7’,
‘muallif’: ‘SH.Mengliyev’,
‘yil’:2019,
‘adadi’:250},
}
print(kitob)
{'kitob1': {'nom': 'Python asoslari',
'muallif': 'M.Mamarajabov', 'yil': 2021,
'adadi': 500},
'kitob2': {'nom': 'C++', 'muallif':
'R.Turayev', 'yil': 2020, 'adadi': 200},
'kitob3': {'nom': 'PHP7', 'muallif':
'Sh.Mengliyev', 'yil': 2019, 'adadi':
250}}
Dostları ilə paylaş: