Bắt đầu ngayBắt đầu miễn phí

Create untyped dict, iterate

A dictionary can be thought of as similar to NamedTuples, which we have already worked with. We assign a name, or in the case of a dictionary, a key, to each value (or group of values). This key (or name) can then be used to access the values that are assigned to it.

This is incredibly useful for storing large amounts of data where we need to know what we are accessing. If you ever work with an API or any automated data feeds, it is a near certainty that you will encounter a dictionary-like structure called JSON, which is traversed in much the same way as a dictionary.

In these exercises, create a dictionary apple_stock_data and iterate over it to return the values inside it.

Bài tập này là một phần của khóa học

Intermediate Julia

Xem khóa học

Bài tập tương tác thực hành trực tiếp

Hãy thử làm bài tập này bằng cách hoàn thành đoạn mã mẫu này.

# Create a dictionary with three keys and assign the given values to each key
apple_stock_data = ____("price" => ____, "prev_close" => ____, ____ => 55000000)
Chỉnh sửa và Chạy Mã