Geliştiriciler için Python’a Giriş
Jasmin Ludolf
Senior Data Science Content Developer
ingredients = ["pasta", "tomatoes", "garlic", "basil", "olive oil", "salt"]# Malzeme miktarları (gram) quantities = [500, 400, 15, 20, 30, 5]

usernameemailpreferences
ip_addresslocation$$


# Bir sözlük oluşturma
recipe =
# Bir sözlük oluşturma
recipe = {
# Bir sözlük oluşturma
recipe = {"pasta"
# Bir sözlük oluşturma
recipe = {"pasta":
# Bir sözlük oluşturma
recipe = {"pasta": 500
# Bir sözlük oluşturma
recipe = {"pasta": 500,
# Bir sözlük oluşturma
recipe = {"pasta": 500,
"tomatoes": 400,
# Bir sözlük oluşturma
recipe = {"pasta": 500,
"tomatoes": 400,
"garlic": 15,
"basil": 20,
"olive oil": 30,
"salt": 5
# Bir sözlük oluşturma
recipe = {"pasta": 500,
"tomatoes": 400,
"garlic": 15,
"basil": 20,
"olive oil": 30,
"salt": 5}
Sözlükler sıralıdır
Ne kadar pasta gerekir?
# Malzeme miktarını bul
print(recipe["pasta"])
500
# Bir sözlükten tüm değerleri al
print(recipe.values())
dict_values([500, 400, 15, 20, 30, 5])
# Bir sözlükteki tüm anahtarları al
print(recipe.keys())
dict_keys(['pasta', 'tomatoes', 'garlic', 'basil', 'olive oil', 'salt'])
# Sözlüğü yazdır
print(recipe)
{'pasta': 500, 'tomatoes': 400, 'garlic': 15, 'basil': 20, 'olive oil': 30,
'salt': 5}
# Tüm öğeleri (anahtar-değer çiftleri) al
print(recipe.items())
dict_items([('pasta', 500), ('tomatoes', 400), ('garlic', 15), ('basil', 20),
('olive oil', 30), ('salt', 5)])
# Yeni bir anahtar-değer çifti ekle
recipe["parmesan"] = 50
print(recipe)
{'pasta': 500, 'tomatoes': 400, 'garlic': 15, 'basil': 20, 'olive oil': 30,
'salt': 5, 'parmesan': 50}
print(recipe)
{'pasta': 500, 'tomatoes': 400, 'garlic': 15, 'basil': 20, 'olive oil': 30,
'salt': 5, 'parmesan': 50}
# Var olan bir anahtarın değerini güncelleme
recipe["pasta"] = 1000
print(recipe)
{'pasta': 1000, 'tomatoes': 400, 'garlic': 15, 'basil': 20, 'olive oil': 30,
'salt': 5, 'parmesan': 50}
# Yinelenen anahtarlı bir sözlük oluşturma recipe = {"pasta": 500, "garlic": 5, "garlic": 15, "basil": 20, "olive oil": 30, "salt": 5}# Yinelenen anahtarın değerini yazdır print(recipe["garlic"])
15
Geliştiriciler için Python’a Giriş