BaşlayınÜcretsiz Başlayın

Working with dictionaries

So far, you've added the ingredients with their quantities in grams.

Now, you want to practice accessing the dictionary's contents using different methods to confirm the dictionary is set up as expected, and to prepare for scaling later on.

Bu egzersiz

Introduction to Python for Developers

kursunun bir parçasıdır
Kursu Görüntüle

Egzersiz talimatları

  • Use a method to retrieve all the keys from the recipe dictionary and assign the result to ingredient_names.
  • Use a method to retrieve all the values from the recipe dictionary and assign the result to quantities.
  • Use a method to retrieve all key-value pairs from the recipe dictionary and assign the result to recipe_items.

Uygulamalı interaktif egzersiz

Bu örnek kodu tamamlayarak bu egzersizi bitirin.

# Get all ingredient names
ingredient_names = ____

# Get all quantities
quantities = ____

# Get all key-value pairs
recipe_items = ____

print("Ingredient names:", ingredient_names)
print("Quantities:", quantities)
print("Recipe items:", recipe_items)
Kodu Düzenle ve Çalıştır