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

Modify keys/values in dict, use get()

We have seen how to create and access values within a dictionary, so the next step is to look at modifying the values within a dictionary. Remember that to access the values within a dictionary, we use the associated key.

Bu egzersiz

Intermediate Julia

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

Egzersiz talimatları

  • Change the price to 132.55.
  • Change the volume to 70000000
  • Use the get() keyword to print the new price() value to the console, setting the default argument for get() to Unknown key.

Uygulamalı interaktif egzersiz

Bu örnek kodu tamamlayarak bu egzersizi bitirin.

apple_stock_data = Dict{String, Float64}("price" => 131.86, "prev_close" => 131.99, "volume" => 55000000)

# Change the price and volume values
apple_stock_data____ = ____
apple_stock_data____ = ____

# Use get() to get the price key in apple_stock_data
println(____(____, ____, ____))
Kodu Düzenle ve Çalıştır